我花了一些时间试图弄清楚当应用scale_x_datetime时为什么小时刻度被移动了。我已经尝试在创建日期/时间列时给出时区。我从包规模中使用了ggplot和scale_x_datetime()。小时滴答是错误的,哪个数据点与其日期/时间列中的时间不匹配。
以下是处理我的数据集的一些过程。
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"))
我在这里错过了吗?请帮我解决一下。 非常感谢!