EDIT: clarifying per @Gregor's comment, I would like to set bounds in the context of stat_summary
- in this case actually zooming out from the default. Only pre-mean data falls out side my desired bounds. Then, I'd like to set breaks, which seems to require the use of scale_continuous
.
I've looked around for a while, and at least some mailing list posts describe "problem(s) that new users sometimes have" with setting scales.
However, while I am no longer confused at that level about scale_continuous
censoring out-of-bounds data, it seems I am reduced to the following awkward code to specify breaks if using stat_summary:
ggplot(data, aes(x=trial, linetype=PrimaryDx, y=mTT, color=hand)) +
stat_summary(fun.y = mean, geom = "line") +
scale_y_continuous(limits = c(1,2), breaks = seq(1, 2, 0.2),
oob=function(x, r) x) ## This seems silly
Here, scale_y_continuous of course will censor out-of-bounds data by default. I supply a simple identity function in place of oob=censor
.
For the life of me, I can find no other way to specify breaks than with scale_([xy]_)?continuous
functions. [xy]lim
and coord_cartesian
both only set limits.
Is the above is the only way to do it? If so, then maybe that at least warrants a place in the vignettes? (or if there is a better way, then maybe that should go in the vignettes.)