我的数据帧为df,我想从这个数据帧中绘制一个多边形。我使用下面的代码,但x轴以数字显示,而不是实际日期。如何解决问题?提前谢谢。
df:
date v1 v2 v3 v4 ...
01/09/2012 12 13 11
01/12/2012 13 15 10
01/20/2012 14 16 20
02/11/2012 10 17 18
# Presumably you are using pkg:lubridate, so this would be courteous
library(lubridate)
day = mdy(df$date)
conts = rowSums(df[,2:3][,])
conty = c(0,conts,0)
contx = c(day[1],day,day[length(day)])
plot(0,0,xlim=range(day),ylim=range(rowSums(df[,2:3])),type='n')
polygon(contx,conty,xlim=range(day),col='red')