I've been learning ggplot in the last few weeks. Generally, I'm getting things done (slowly though), but now I'm stuck. I created the following facetted plot: http://dl.dropbox.com/u/7752237/example_bad_y_scales.pdf
Faceting is done by
pl <- pl + facet_wrap(~sci_name,ncol=1,scale="free")
The Problem: Numbers on the y-scale don't look good, especially the scales that go from 0-70 (numbers overlapping). I'd like the somehow change the number of breaks on the y-scale (to let's say just 1 or 2 breaks). Does anybody maybe have an idea how to do that? Any help would be very much appreciated. :)
PS: I didn't include a minimal example because I think it wouldn't help much to solve that specific problem.
Edit after Kohskes answer:
Hi Kohske, Wow, that was a really fast answer, thanks! However, I think it doesn't work well with facetted plots. Look at
p <- ggplot(mtcars, aes(wt, mpg))
p <- p + geom_point()
p <- p + facet_wrap(~gear,ncol=1,scale="free")
On the y-scale, it gives 3 breaks in the middle plot and 8 breaks in the lower plot… not very consistent (but at least not overlapping as in my example).
p2 <- p + scale_y_continuous(breaks=c(15,30),minor_breaks=c(10,20,25))
isn't really good neither: two major ticks on lower plots, only one in middle and upper plot. When having scales with bigger differences than in mtcars, the result would be even less satisfying. Any other ideas? ;)
Edit after Kohskes edit:
Hi, I can't see how to implement this. Searching for ggplot and input_break on google yielded only 10 results, none of them did help. I tried
p <- ggplot(mtcars, aes(wt, mpg))
p <- p + geom_point()
p <- p + facet_wrap(~gear,ncol=1,scale="free")
p$input_breaks<-function(., range) {
pretty(range, n=3)
}
print(p)
However, I can't see any effects in the graph (tried for n=1, 3, 15). Could you describe how to implement this on the mtcars example? Thanks!