title: Different colours for different facet_grids
body: <p>I am having a hard time getting different colours for my 2 different facet_grids.</p>
  
  <p>Here is my simple example:</p>
  
  <pre><code>df &lt;- data.frame(x = rep(1:20, each=20), y= rep(1:20, 20),
               val = sample(0:1,400, replace=TRUE),
               facet_grid = c(rep("A", 200), rep("B", 200)))
  colors &lt;- c(1,2)
  ggplot(df, aes(x = x, y = y)) +
      geom_tile(aes(fill = val)) +
      facet_grid(. ~ facet_grid, scales = "free") +
      scale_fill_gradient(limits=c(0,1), low=brewer.pal(11, "RdYlGn")[colors][1],  
                          high="grey30")
  </code></pre>
  
  <p>I am using the <code>scale_fill_gradient</code> function with the <code>brewer.pal</code> function to override the standard colours used. However, what I am trying to achieve is set in the two different facet_grids for values that are 1 the same colour (grey30) should be used. For values that are 0 in the first facet_grig, for instance, red should be used and in the second facet_grid green should be used.</p>
  
  <p>Can anybody give me a hint on how to achieve that?</p>
  
  <p>I created another example which is now closer to want I want but I do not understand why <code>scale_fill_identity</code> does not work. For that I slightly changed the data frame so that value has now 4 different values:</p>
  
  <pre><code>df &lt;- data.frame(x = rep(1:20, each=20), y= rep(1:20, 20),
               val = c(sample(0:1,200, replace=TRUE), sample(2:3,200, replace=TRUE)),
           facet_grid = c(rep("A", 200), rep("B", 200)))
  
  ggplot(df, aes(x = x, y = y)) +
      geom_tile(aes(fill = val)) +
      facet_grid(. ~ facet_grid, scales = "free")
  
  ggplot(df, aes(x = x, y = y)) +
      geom_tile(aes(fill = val)) +
      facet_grid(. ~ facet_grid, scales = "free")
  
  scale_fill_identity(labels=letters[1:4], breaks=c("red","blue","green","brown")) +
  </code></pre>
  
  <p>The first ggplot gives me almost what I want. 4 different colours in the two different facet_grids. I tried to use <code>scale_fill_identity</code> to change the 4 colours but what I get in my plot are 4 different colours black/white and red/green and not the ones specified above.</p>