title: How to modify the legend of a heat map generated with ggplot's geom_tile?
body: <p>Is there a way to modify the legend of a heat map that was generated with <a href="http://had.co.nz/ggplot2/geom_tile.html" rel="nofollow">geom_tile</a> from the ggplot2 package? I would like to increase the number of tiles in the legend and to set the minimum and maximum of the shown value there.</p>
  
  <p>In this example from the manual page the legend contains five colored tiles representing values from -0.4 to 0.4. How could I let e.g. 9 tile be displayed instead?</p>
  
  <pre><code>library (ggplot2)
  
  pp &lt;- function (n,r=4) {
     x &lt;- seq(-r*pi, r*pi, len=n)
     df &lt;- expand.grid(x=x, y=x)
     df$r &lt;- sqrt(df$x^2 + df$y^2)
     df$z &lt;- cos(df$r^2)*exp(-df$r/6)
     df
  }
  
  p &lt;- ggplot(pp(20), aes(x=x,y=y))
  p + geom_tile(aes(fill=z))
  </code></pre>