title: ggplot2 change fill for color legend when fill also used in aesthetic
body: <p>Is there a way to control the fill for the color legend when fill is also used in the aesthetic in ggplot2?</p>
  
  <p>Ex. </p>
  
  <pre><code>dat&lt;-data.frame(id=as.character(1:4), var1=rep(LETTERS[1:2], 2), var2=rep(LETTERS[3:4], 2))
  dat
  library(ggplot2)
  
  ggplot(dat)+
    geom_bar(aes(id, color=var1, fill=var2))+
    scale_color_manual(values=c("A"="black", "B"="grey"))+
    theme_light()
  </code></pre>
  
  <p>In this legend it is very hard to see the light grey border around the darker gray fill in the color legend.  I will admit it may not be a good practice to specify color and fill in the same plot as it can become difficult to understand which color means what and the colored borders around the filled objects can be hard to differentiate, but how would I do it if I wanted to? </p>
  
  <p><a href="https://i.stack.imgur.com/mKTlU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mKTlU.png" alt="Here the background color for the color variable makes it difficult to see the grey outline"></a></p>
  
  <p>By manually specifying fill in the plot, the fill color in the legend can be controlled when not also specifying fill. </p>
  
  <pre><code>ggplot(dat)+
    geom_bar(aes(id, color=var1), fill="white")+
    theme_light()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/9j1vH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9j1vH.png" alt="enter image description here"></a>
  I thought there would be a way to control this using an argument in theme, but <code>theme(legend.background=element_rect())</code> controls the background of the whole legend (and rightly so)</p>
  
  <pre><code>ggplot(dat)+
    geom_bar(aes(id, color=var1, fill=var2))+
    scale_color_manual(values=c("A"="black", "B"="grey"))+
    theme_light()+
    theme(legend.background = element_rect(fill="blue"))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/tYllK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tYllK.png" alt="enter image description here"></a></p>
  
  <p>Also in theme, <code>theme(legend.key = element_rect(fill="blue"))</code> only adds a thin blue line around the <code>var2</code> boxes in the legend, <code>legend.box</code> controls the arrangement of multiple legends ("horizontal" or "vertical"), and <code>theme(legend.box.background = element_rect(fill="blue"))</code> colors the background between the <code>var1</code> and <code>var2</code> legends.  </p>
  
  <p>I thought perhaps the legend was using the default value for NA for the fill, so I tried specifying this manually using <code>scale_color_discrete()</code></p>
  
  <pre><code>ggplot(dat)+
    geom_bar(aes(id, color=var1, fill=var2))+
    scale_color_manual(values=c("A"="black", "B"="grey", 
                                na.translate=TRUE, na.value = "white"))+
    theme_light()
  </code></pre>
  
  <p>Looks the same as the first plot.  </p>
  
  <p>This seems like something that should be controlled by an argument in <code>theme()</code> or <code>scale_color_manual</code>, but I can't seem to figure it out.<br>
  Cheers </p>