如何更改日期轴的中断+将它们旋转90度

问题描述 投票:1回答:1

我怎么可能改变timeSeries::plot函数的中断+使它们垂直?

我的尝试是:

library(timeSeries)
test_xlab = as.Date(paste0("2000-01-",10:16))

timeSeries::plot(as.timeSeries(seq(10,70,10), 
                                charvec = test_xlab),
                  axes = F);box()

axis.Date(side = 1,
          x = test_xlab[c(1,2,7)], 
          at = test_xlab[c(1,2,7)], 
          format = "%a", las = 2)

enter image description here

我用上面的代码瞄准的结果是只能在x轴标签上显示一周7天中的3天并垂直显示它们。

现在,我能够以某种方式对其进行格式化,以便显示一周中的所有日期,如果该函数用作:

timeSeries::plot(as.timeSeries(seq(10,70,10), charvec = test_xlab), format = "%a", axes = T)

生成的图如下,

enter image description here

该情节在葡萄牙语缩写中有一周的日子,因此尝试的将有而不是Seg,Ter, Qua, ..., Dom - > Seg,Ter, Dom显示。

r plot time-series
1个回答
1
投票

axis.timeDate一样使用las=2

library(timeSeries)

tt <- timeSeries(seq(10,70,10), as.Date("2000-01-10") + 0:6)

plot(tt, axes = FALSE)
box()
ok <- as.numeric(format(time(tt), "%w")) %in% 0:2
axis.timeDate(1, at = time(tt)[ok], format = "%a", las = 2)

screenshot

© www.soinside.com 2019 - 2024. All rights reserved.