5

I created a faceted set of three univariate densities -- comparing MCMC methods. Shown below

enter image description here

For the moment, I don't care about the tails. So how can I change the x-axis limits on the plots above to be:

c(-3,1)
c(-2,0)
c(-10, -8)

Is this even possible? I've already read this thread from 2009, but it doesn't seem to work. Was this implemented?

M. Tibbits
  • 8,400
  • 8
  • 44
  • 59
  • For ref, I tried adding `scale.x.limits` to my facet_grid call and got: `unused argument(s) (scale.x.limits = c(-3, -1, -2, 0, -10, -8))` – M. Tibbits Jul 04 '11 at 17:01

1 Answers1

2

You can always allow limits to be set independently for each facet by specifying

+ facet_wrap(...,scales = "free_x")

There are also "free" and "free_y" options.

joran
  • 169,992
  • 32
  • 429
  • 468
  • AKAIK, what you're describing is not currently implemented, but I *think* I read somewhere that something like this may be in the works for future versions. One option would be to subset your data using those limits via `ddply` and then plot the subset of your data. – joran Jul 04 '11 at 17:32
  • What you recommended works. So I've accepted your answer, though it isn't really what I wanted. In the link I provided above, Hadley [mentioned](http://groups.google.com/group/ggplot2/browse_thread/thread/703ccbff21dec342/a49a69bad79767f5?lnk=gst&q=limit+scale+facet#a49a69bad79767f5) working on this in January of 2010. So I was/am still hoping it was implemented. **But for now, your suggestion works perfectly!** Thanks! – M. Tibbits Jul 04 '11 at 17:38
  • For what it's worth, [here's](http://groups.google.com/group/ggplot2/browse_thread/thread/703ccbff21dec342/a49a69bad79767f5?lnk=gst&q=limit+scale+facet#a49a69bad79767f5) the discussion I was remembering. That was over a year ago, though. – joran Jul 04 '11 at 17:39