R中的直方图和日期位置
当我绘制直方图时,它看起来不在正确的日期 我的数据是这样的R中的直方图和日期位置,r,datetime,ggplot2,histogram,R,Datetime,Ggplot2,Histogram,当我绘制直方图时,它看起来不在正确的日期 我的数据是这样的 date tcol names 2005-03-31 170 Site 4 2005-03-31 328 Site 5 2005-03-31 40 Site 6 我的代码看起来像 ggplot(data=allsite, aes(x=date, weight=tcol, colour=names, fill=names))+ geom_histogram(binwidth=20000
date tcol names
2005-03-31 170 Site 4
2005-03-31 328 Site 5
2005-03-31 40 Site 6
我的代码看起来像
ggplot(data=allsite, aes(x=date, weight=tcol, colour=names, fill=names))+
geom_histogram(binwidth=20000, position=position_dodge())+
scale_y_continuous(limits=c(0,1000))+
scale_x_datetime(labels = date_format("%d-%m-%y"),
limits = as.POSIXct(c("2005-03-29","2005-04-02")))
看起来好像数据是3号的30号,而不是31号
感谢您提供的任何帮助:)您需要在as.POSIXct中指定时区
limits = as.POSIXct(c("2005-03-29","2005-04-02"), tz="GMT"))
快速看一眼,它与您的x比例有关,因为每个限制也向后移动了1。问题似乎出在这行
limits=as.POSIXct(c(“2005-03-29”,“2005-04-02”)
尝试scale\u x\u date()并将as.date()用作限制