作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
我正在尝试使用 ggplot2 绘制一个 x 轴为“POSIXct”类的时间序列,它正在达到一定程度。
当我尝试使用 scale_x_datetime
操纵 x 轴中断和标签时,它会在 x 轴上产生一个月的偏移。
谁能解释一下,并提供解决方案?
示例简化代码:
start <- as.POSIXct("2014/07/01 00:00:00")
end <- as.POSIXct("2014/10/01 23:30:00")
interval <- as.difftime("00:30:00")
df <- data.frame(t=seq(start, end, by="1 day"))
df$v <- sample(1:100, replace=TRUE, nrow(df))
p <- ggplot(data=df, aes(x=t)) +
geom_line(aes(y=v))
p2 <- p + scale_x_datetime(breaks=date_breaks("1 month"), labels=date_format("%b-%y"))
这个问题在这里已经有了答案: Time series plot gets offset by 2 hours if scale_x_datetime is used (2 个答案) 关闭 6 年前。
我似乎在 ggplot2 0.9.0 documentation 上找不到信息, 0.9.0 过渡指南,或搜索。 我猜在早期版本中,您会将 tz 参数添加到 scale_x_datetime。我尝试将
我是一名优秀的程序员,十分优秀!