title: Equalize the range of the values in legends for multiple ggplots
body: <p>I have a huge data frame with multiple columns that I would like to make multiple tsne plot based on two first columns and colored by other variables in each plot. Here is a sample of my data frame like this:</p>
  <pre><code>library(tidyverse)
  
  dat &lt;- tribble(
   ~NE1,  ~NE2,   ~A, ~B,
  4.179,  10.506, 1.247,  7.540,
  -7.544, 2.877,  1.265,  7.296,
  1.485,  -37.57, 1.254, 6.173,
  4.412,  -32.117,    1.185,  6.221,
  -10.403,    31.718, 1.259,  7.607,
  9.283,  8.213,  1.250,  7.682,)
  </code></pre>
  <p>I would like to have same scale limits for all of the plot but I don't know how to equalize the range od legend in all plots. I used this code:</p>
  <pre><code>p1&lt;-ggplot(dat,  aes(x = NE1, y = NE2, color = A)) +
    geom_point(size = 0.8) +
    theme_bw() + 
    scale_color_gradientn(&quot;A&quot;, 
                          colours = colorRampPalette(rev(brewer.pal(n = 11, name = &quot;Spectral&quot;)))(50))
  
  p2&lt;-ggplot(dat,  aes(x = NE1, y = NE2, color = B)) +
    geom_point(size = 0.8) +
    theme_bw() +
    scale_color_gradientn(&quot;B&quot;, 
                          colours = colorRampPalette(rev(brewer.pal(n = 11, name = &quot;Spectral&quot;)))(50))
  grid.arrange(p1, p2, nrow = 1)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/v0lr4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v0lr4.png" alt="enter image description here" /></a></p>