title: How do you set different scale limits for different facets?
body: <p>Some sample data:</p>
  
  <pre><code>dfr &lt;- data.frame(
    x = rep.int(1:10, 2),
    y = runif(20),
    g = factor(rep(letters[1:2], each = 10))
  )
  </code></pre>
  
  <p>A simple scatterplot with two facets:</p>
  
  <pre><code>p &lt;- ggplot(dfr, aes(x, y)) + 
    geom_point() +
    facet_wrap(~ g, scales = "free_y")
  </code></pre>
  
  <p>I can set the axis limits for all panels with</p>
  
  <pre><code>p + scale_y_continuous(limits = c(0.2, 0.8))
  </code></pre>
  
  <p>(or a wrapper for this like <code>ylim</code>)</p>
  
  <p>but how do I set different axis limits for different facets?</p>
  
  <p>The latticey way to do it would be to pass a list to this argument, e.g.,</p>
  
  <pre><code>p + scale_y_continuous(limits = list(c(0.2, 0.8), c(0, 0.5)))
  </code></pre>
  
  <p>Unfortunately that just throws an error in the ggplot2 case.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here's a partial hack.  If you want to extend the range of the scales then you can add columns to your dataset specifying the limits, then draw them with <code>geom_blank</code>.</p>
  
  <p>Modified dataset:</p>
  
  <pre><code>dfr &lt;- data.frame(
    x = rep.int(1:10, 2),
    y = runif(20),
    g = factor(rep(letters[1:2], each = 10)),
    ymin = rep(c(-0.6, 0.3), each = 10),
    ymax = rep(c(1.8, 0.5), each = 10)
  )
  </code></pre>
  
  <p>Updated plot:</p>
  
  <pre><code>p + geom_blank(aes(y = ymin)) + geom_blank(aes(y = ymax))
  </code></pre>
  
  <p>Now the scales are different and the left hand one is correct.  Unfortunately, the right hand scale doesn't contract since it needs to make room for the points.</p>
  
  <p>In case it helps, we can now rephrase the question as "is it possible to draw points without the scales being recalculated and without explicitly calling <code>scale_y_continuous</code>?"</p>