[R] Double x grid in ggplot2
James Rome
jamesrome at gmail.com
Fri Jun 10 20:08:58 CEST 2011
I am trying to overlay raw data with a boxplot as follows:
pp = qplot(factor(time, levels=0:60, ordered=TRUE),
error, data=dfsub, size=I(1), main =" title", ylab="Error
(min)",
xlab="Time before ON (min)", alpha=I(1/10),
ylim=c(-30,40), geom="jitter") +
facet_wrap(~ runway, ncol=2) +
geom_boxplot(alpha=.5, color="blue", outlier.colour="green",
outlier.size=1) +
scale_x_discrete(breaks = seq(from=0, to=60, by=10))
print(pp)
But I think ggplot2 is getting confused about factors versus numbers
> sapply(dfsub,class)
time error runway flight
"numeric" "numeric" "factor" "factor"
because when I do the plot, the vertical grid lines are in pairs, one
line at (0, 10, 20,...) and the other at (-1, 9, 19,....)
If I remove the scale_x_discrete, I get a grid line at every minute,
and things look right, but the labels for the minutes all overlap.
Thanks for the help,
Jim Rome
More information about the R-help
mailing list