title: Invert continuous color scale legend in ggplot geom_tile heatmap
body: <p>Minimal example:</p>
  <pre><code>library(ggplot2)
  x &lt;- c(1:3)
  y &lt;- c(1:3)
  data &lt;- expand.grid(X=x, Y=y)
  data$Z &lt;- runif(9)
  ggplot(data, aes(X, Y, fill=Z)) +
    geom_tile()
  </code></pre>
  <p>Produces this:</p>
  <p><a href="https://i.stack.imgur.com/vCO7k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vCO7k.png" alt="plot" /></a></p>
  <p>How do you get the Z scale bar on the right to run from 0 on top to 1 on the bottom? instead of from bottom to top?</p>
  <p>I'm trying to emphasize smaller values, and actually would like for this to work with viridis or magma color scheme if possible. But <code>direction=-1</code> on <code>scale_fill_viridis</code> only flips the color scale. Would like yellow = 0, blue/black = 1. Then Z scale to go from blue to yellow from bottom to top.</p>
  <pre><code>ggplot(data, aes(X, Y, fill=Z)) +
    geom_tile() +
    scale_fill_viridis(discrete=FALSE, direction=-1)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/d13Xn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d13Xn.png" alt="viridis" /></a></p>