Although I found a Hadley entry in the google group on POSIXct and geom_vline , I was not able to do it. I have time series and would like to draw a vertical line during the years 1998, 2005 and 2010, for example. I tried using the syntax ggplot and qplot , but still I either do not see the vertical line at all, or the vertical line is drawn in the very first vertical grid, and the whole series is shifted somewhat strangely to the right.
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
My date field is in the format "1993-07-01" and has a Date class.
date r time-series ggplot2
Matt Bannert Mar 22 '11 at 9:01 2011-03-22 09:01
source share