我有一个在0.8.9工作得很好,但不是在0.9.1一些ggplot代码。
我要绘制数据theDF
,并想在绘制垂直线xintercept="2010 Q1."
theGrid
只是用来创建theDF
。
theGrid <- expand.grid(2009:2011, 1:4)
theDF <- data.frame(YrQtr=sprintf("%s Q%s", theGrid$Var1, theGrid$Var2),
Minutes=c(1000, 2200, 1450, 1825, 1970, 1770, 1640, 1920, 1790, 1800, 1750, 1600))
所使用的代码是:
g <- ggplot(theDF, aes(x=YrQtr, y=Minutes)) +
geom_point() +
opts(axis.text.x=theme_text(angle=90))
g + geom_vline(data=data.frame(Vert="2010 Q2"), aes(xintercept=Vert))
同样,这工作得很好R中2.13.2与GGPLOT2 0.8.9,但GGPLOT2 0.9.1不中的R 2.14+。
一种解决方法是:
g + geom_vline(data=data.frame(Vert=4), aes(xintercept=Vert))
但是,这不是我的问题一个很好的解决方案。
也许瞎搞与scale_x_discrete
可能帮助?