【发布时间】:2016-03-25 19:59:55
【问题描述】:
我花了一些时间试图弄清楚为什么在应用 scale_x_datetime 时小时刻度会发生变化。我试图在创建日期/时间列时给出时区。我使用了 ggplot 和 scale_x_datetime() 包中的 scales。小时刻度错误,哪个数据点与其日期/时间列中的时间不匹配。
这是处理我的数据集的一些程序。
DF$DateTime<-as.POSIXct(DF$timestamp,format="%m/%d/%y %H:%M", tz="America/Toronto")
DF$Date<-as.Date(DF$DateTime)
lims <- as.POSIXct(strptime(c("2015-07-21 00:00","2015-07-23 00:00"), format = "%Y-%m-%d %H:%M"), tz="America/Toronto")
ggplot(DF) + geom_line(aes(x=DateTime, y=-Diff,group=Date)) + scale_x_datetime(limits =lims, breaks=date_breaks("2 hour"), labels=date_format("%m/%d %H:%M"))
我错过了什么吗?请帮我弄清楚。 非常感谢!
【问题讨论】: