On 12/23/2011 08:26 AM, Albert-Jan Roskam wrote: > Hello, > > I am trying to make a plot using the code below. The plot is divided into two > parts, using facet_grid. I would like the vertical axis (labelled 'place') to > be different for each location (=part). So in the upper part, only places 'n' > through 'z' are shown, while in the lower part, only places 'a' through 'm' > are shown. I thought 'free_y' would do the trick. I also tried converting > variable place into class 'factor'. > > > require(ggplot2) > DF <- data.frame(place=letters, value=runif(26), location=c(rep(1, 13), > rep(0, 13))) > qplot(data=DF, x=place, y=value, geom="bar", stat="identity") + > coord_flip() + > geom_abline(intercept=35, slope=0, colour="red") + > facet_grid(location ~ ., scales="free_y") > R.version.string # "R version 2.10.1 (2009-12-14)"
Hi, This code using facet_wrap works: require(ggplot2) DF <- data.frame(place=letters, value=runif(26), location=c(rep(1, 13), rep(0, 13))) qplot(data=DF, x=place, y=value, geom="bar", stat="identity") + coord_flip() + facet_wrap(~ location, scales = "free", ncol = 1) And using facet_grid: DF <- data.frame(place=letters, value=runif(26), location=c(rep(1, 13), rep(0, 13))) qplot(data=DF, x=place, y=value, geom="bar", stat="identity") + coord_flip() + facet_grid(. ~ location, scales = "free") Note that I switched the formula in facet_grid. However, I would expect your code to also work. cheers and hope this helps, Paul > > Thank you in advance & merry xmas! > > Cheers!! > Albert-Jan > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > All right, but apart from the sanitation, the medicine, education, wine, > public order, irrigation, roads, a fresh water system, and public health, > what have the Romans ever done for us? > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > [[alternative HTML version deleted]] > > > > ______________________________________________ > R-help@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. -- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 [[alternative HTML version deleted]] ______________________________________________ R-help@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.