相关疑难解决方法(0)

如何将一个垂直geom_vline转换为类日期的x轴?

即使我发现哈德利对谷歌的论坛中发帖POSIXctgeom_vline,我无法完成它.我有一个时间序列,并希望绘制1998年,2005年和2010年的垂直线.我尝试使用ggplotqplot语法,但我仍然看不到垂直线,或者在第一个垂直网格上绘制垂直线,整个系列在右边有点奇怪地移动.

gg <- ggplot(data=mydata,aes(y=somevalues,x=datefield,color=category)) +
      layer(geom="line")
gg + geom_vline(xintercept=mydata$datefield[120],linetype=4)
# returns just the time series plot I had before, 
# interestingly the legend contains dotted vertical lines
Run Code Online (Sandbox Code Playgroud)

我的日期字段格式为"1993-07-01",属于班级Date.

r date time-series ggplot2

93
推荐指数
3
解决办法
6万
查看次数

标签 统计

date ×1

ggplot2 ×1

r ×1

time-series ×1