Ho qualche codice ggplot che ha funzionato bene in 0.8.9 ma non in 0.9.1.geom_vline con Character xintercept
ho intenzione di tracciare i dati in theDF
e vorrebbe tracciare una linea verticale a xintercept="2010 Q1."
theGrid
è semplicemente utilizzato per creare 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))
Il codice utilizzato è:
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))
nuovo, questo funzionava bene in R 2.13.2 con ggplot2 0.8.9, ma non fa in R 2.14+ con ggplot2 0.9.1.
Una soluzione è:
g + geom_vline(data=data.frame(Vert=4), aes(xintercept=Vert))
Ma non è una buona soluzione per il mio problema.
Forse scherzare con scale_x_discrete
potrebbe essere d'aiuto?
Questo non è riproducibile senza 'theVerts' (che presumo sia un frame di dati?). – joran
@joran Ho avuto 'dati =' in 'aes' per caso. È stato riparato ora, il valore di riferimento è stato sostituito da 'data.frame (Vert =" 2010 Q2 ")'. – Jared
Sembra un bug. Puoi presentare un problema a: https://github.com/hadley/ggplot2/issues – wch