Re: [R] Setting scales for ggplot2 with facets
Sorry, I was too vague in my initial question. To make it clearer I included the following example: tmp - data.frame(y=runif(10), x=gl(2,5), class=gl(2,5)) p - ggplot(data = tmp) p - p + geom_point(aes(y=y, x=x)) p - p + facet_wrap(~ class, scales = free) p - p + ylim(0, 1) p This code draws two facets each having 5 points. As explained before, I would like to control y-range of both facet plots. For clarity, say that ylim = c(0, 0.5) for the facet 1 and ylim = c(0.5, 3) for the facet 2. How should I do it? As a quick hack I could, eliminate outliers for both facets, i.e. write lines tmp - cbind(subset(tmp, class == 1 y = 0.5), subset(tmp, class == 2 y = 0.5)) before plotting but this would work only for simple geometrics. For geom_boxplot it would skew the distribution. Swen Laur [[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.
[R] Setting scales for ggplot2 with facets
Faceting in ggplot2 seems to permit different scales for different facets, but I fail to see how one could control ylim and xlim ranges for each facet separately. For instance, I would like to set the ylim = c(0,10) for facet A and ylim = c(42,102) for facet B. Since the data is out of these ranges, setting facet_grid(factor ~ ., scales = free_y) does not achieve the goal . Is there a decent way to achieve this or not? or I have to drop data points outside y-ranges as a quick hack? Swen Laur __ 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.
Re: [R] Setting scales for ggplot2 with facets
This does not solve the problem, as I still do not know how to control the y-range for individual facets. Data contains some outliers which make the y-range too wide for me and I would explicitly set the ylim = c(0,10) for facet A and ylim = c(42, 102) for facet B. How should I do it? On 11 Sep 2010, at 23:37, Jonathan Christensen wrote: Swen, facet_grid forces the scale for plots along an axis to be shared. Try facet_wrap instead. Jonathan On Sat, Sep 11, 2010 at 2:21 PM, Sven Laur s...@math.ut.ee wrote: Faceting in ggplot2 seems to permit different scales for different facets, but I fail to see how one could control ylim and xlim ranges for each facet separately. For instance, I would like to set the ylim = c(0,10) for facet A and ylim = c(42,102) for facet B. Since the data is out of these ranges, setting facet_grid(factor ~ ., scales = free_y) does not achieve the goal . Is there a decent way to achieve this or not? or I have to drop data points outside y-ranges as a quick hack? Swen Laur __ 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. Swen Laur [[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.
[R] Problem with S4 generic function print
First, if I have an S4 class boo should I define S3 method for printing print.boo(..) or should I define S4 method print(..). I mainly need to define print function only because some user might call it and then I would like to dispatch the call to right function instead. Second, it seems that by defining S4 generic function print, it is possible to break argument hinting on the status bar. Namely, as I understand, the Mac OS X GUI client makes a call args() if something like letter( is typed to console. Since letter() function does not exists, it should return nothing to the status bar and nothing to console, as I as a user have not entered any call, yet. However, if S4 generic print is defined, a mysterious error message Error in args(letter) : no function to return from, jumping to top level appears after typing letter() without return('\n') to console. It seems bizarre... System is Mac OS X 10.5.8 (PowerPC) R 2.9.1 GUI 1.28 Tiger build 32-bit (5444) R version 2.9.1 (2009-06-26) Minimal amount of code to get the behaviour is if(!isGeneric(print)) {setGeneric(print,useAsDefault=print)} What is the underlying problem? Sven Laur __ 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.