[R] ggplot2: can one have separate ylim for each facet?

From: Etches Jacob <jacob.etches_at_utoronto.ca>
Date: Mon, 17 Nov 2008 16:49:26 -0500


In lattice

#toy data
library(ggplot2)
library(lattice)

x <- rnorm(100)
y <- rnorm(100)
k <- sample(c("Weak","Strong"),100,replace=T)
j <- sample(c("Tall","Short"),100,replace=T)
w <- data.frame(x,y,j,k)

xyplot(y~x|j+k,scales=list(y=list(relation="free")))

will give you a scale in each subplot with a range equal to the range of y within each subplot.

Is this possible using ggplot2?

qplot(x,y,data=w) + facet_grid(j~k) + ylim(-2,2)

produces a plot with the same range in each subplot. Can the lattice behaviour be reproduced in ggplot2?

Thanks,

Jacob Etches



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 17 Nov 2008 - 21:51:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 17 Nov 2008 - 23:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive