--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
> sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United
Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United
Kingdom.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets
methods base
other attached packages:
[1] ggplot2_0.8.8 proto_0.3-8 reshape_0.8.3 plyr_1.0.3
loaded via a namespace (and not attached):
[1] digest_0.4.2 tools_2.11.1
My mistake - I see the problem. My "extreme" example wasn't different
at all. Try changing 0.05 to 0.5. You should see something like the
plot I've attached.
Bob
Can you not use expand_limits() for this?
p + geom_point() + facet_wrap(~
RandFactor, ncol=1, scales="free_y") +
scale_y_continuous(expand=c(0,0)) + expand_limits(y=c(-20,20))
HTH,
baptiste
economics$RandFactor <- c("FactorA","FactorB")
economics$psavert[economics$RandFactor == "FactorB"] <-
economics$psavert[economics$RandFactor == "FactorB"] - 30
p <- ggplot(economics, aes(x=date, y=psavert))
p + geom_point() + facet_wrap(~ RandFactor, ncol=1, scales="free_y")
Now you can see that static expanded limits won't work. I want the
data in each facet to be "centered" vertically, but to expand the
y-limits for each facet so that the minor fluctuations in each facet
are visually minimized.
You're using the expand parameter for a purpose it wasn't designed for
- the point of it is to give a little space between the data and the
ticks, so adding ticks in that gap would defeat the purpose. However,
if you look at the source code for expand_limits, you can see
modifying for your needs is pretty simple. You just construct a data
frame that provides both the y values and the facet values and then
use that with geom_blank.
ranges <- data.frame(RandFactor = c("a", "a", "b", "b"), y = c(1, 100,
1000, 10000))
p + geom_blank(aes(y = y), data = ranges, inherit.aes = FALSE)
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/