title: How can I create a colormap with a fixed color for 0 in R / ggplot
body: <p>I am producing heatmaps of measurement using <code>ggplot2</code>. The data contains positive and negative values and I use the <code>rainbow()</code> palette for coloring.</p>
  
  <p>I have different data sets and would like to scale the colora in a way that the minimum, maximum and 0 values of each data set get the same colors assigned. I could only find out to set the minimum and maximum using <code>limits=...</code></p>
  
  <p>How can I also define a given color for 0?</p>
  
  <p>Here is my minimal example, if I would for example use rainbow(5), I would like the 3rd color to be the zero color.</p>
  
  <pre><code>data &lt;- read.csv("http://protzkeule.de/data.csv")
  ggplot(data=data, aes(x=variable, y=meas)) + 
    geom_tile(aes(fill=value)) + 
    scale_fill_gradientn(colours=rev(rainbow(255)),limits=c(-.2,.4))
  </code></pre>