title: Smart number of decimals in ggplot facet axis labels
body: <p>I have a faceted <code>ggplot</code> like so:</p>
  
  <pre><code>library(ggplot2)
  grid &lt;- seq(-10,10,length.out=1000)
  df &lt;- data.frame(x=rep(grid,2),y=c(grid^2,100+grid^2/100000000),group=rep(c(1,2),each=length(grid)))
  ggplot(df,aes(x,y)) + geom_line() + facet_wrap(~group,scales='free')
  </code></pre>
  
  <p>Problem is that the y-axes values for group 2 are all identical because they only differ in the 6-7th decimal. So I tried</p>
  
  <pre><code>fmt &lt;- function(){
    function(x) format(x,nsmall = 7,scientific = FALSE)
  }
  ggplot(df,aes(x,y)) + geom_line() + facet_wrap(~group,scales='free') + scale_y_continuous(labels = fmt())
  </code></pre>
  
  <p>but that adds a lot of unnecessary decimals for the first group (duh!).</p>
  
  <p>Is there any way to make <code>ggplot</code> show however many decimal places are necessary for the values on the y-axis to all be different for all facets? Or is doing this manually with <code>gridExtra</code> my best bet here?</p>