title: why when we use rev to reverse the colour of legend we get something different?
body: <p>I am trying to plot the image of this raster file. The colour of the legend was like this:  low values with red colour and high values with green. </p>
  
  <p>But normally red colour is associated with high values. That's why I then used <code>rev</code> to reverse the colour of the legend. However I got something different. Is there another function to reverse the colour of the legend and keep the colours as they are.</p>
  
  <pre><code>require(raster)
  require(fields)
  r = raster(y)
  extent(r) = extent(c(xmn=-180,xmx=180,ymn=-90,ymx=90))
  plot(r, col = rainbow(20, s = 1, v = 1, start = 0, 
       end = 1),lab.breaks=seq(0,0.6,0.05),
       breaks=seq(0,0.6,0.05), zlim=c(0.0,0.6),horizontal = TRUE, 
       xlab="Longitude", ylab="Latitude",legend.shrink = 0.9,
       legend.width = 1.2)
  </code></pre>
  
  <p>then I used this which gave me:</p>
  
  <pre><code>plot(r, col = rev(rainbow(20, s = 1, v = 1, start = 0, end = 1)),
       lab.breaks=seq(0,0.6,0.05),breaks=seq(0,0.6,0.05),
       zlim=c(0.0,0.6),horizontal = TRUE, xlab="Longitude", 
       ylab="Latitude",legend.shrink = 0.9,legend.width = 1.2)
  </code></pre>