title: Create a ggplot barchart/histogram with fill and outline colors indicated by different variables
body: <p>I am trying to create a chart in ggplot along these lines:</p>
  
  <p><a href="https://i.stack.imgur.com/JrdYs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JrdYs.png" alt="enter image description here"></a></p>
  
  <p>...in which the color of the boxes is indicated by one variable, and the outline of the boxes is indicated by another variable.</p>
  
  <p>Assuming the data is structured like this:</p>
  
  <pre><code>df&lt;-data.frame(index=1:50,date=sample(seq(as.Date('1999/01/01'), as.Date('1999/06/01'), by="day"), 50,replace=T),
             V1=sample(c("Indigenous","Import-related","Imported","Unknown"), 50,replace=T),
             V2=sample(c(NA,"Zombie","Pulmonary Hemorrhage"), 50,replace=T))
  </code></pre>
  
  <p>All I can think of is something like this:</p>
  
  <pre><code>require(ggplot2)
  #draw the histogram with fill determined by V1
  p&lt;-ggplot(data=df)+geom_histogram(aes(x=date,group=V1,fill=V1),binwidth=7,color="black",alpha=0.9)
  #draw the individual boxes for each case
  p1&lt;-p+scale_fill_discrete()+geom_histogram(aes(x=date,group=index),binwidth=7,color="black",alpha=0)
  #attempt to draw green boxes for one value of V2
  p2&lt;-p1+geom_histogram(aes(x=date,group=V2=="Zombie"),binwidth=7,color="green",alpha=0,size=1.2)
  #attempt to draw orange boxes for the other value of V2
  p3&lt;-p2+geom_histogram(aes(x=date,group=V2=="Pulmonary Hemorrhage"),binwidth=7,color="orange",alpha=0,size=1.2)
  </code></pre>
  
  <p>However, this is not working as it draws borders everywhere and I cannot isolate individual cases using this approach, as you can see.</p>
  
  <p><a href="https://i.stack.imgur.com/HB7AF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HB7AF.png" alt="enter image description here"></a></p>
  
  <p>Is there a ggplot solution? If I can't do colored boxes, I could indicate V2 by some kind of text annotation on the appropriate boxes, but then would have to figure out x and y for each label, and that's giving me fits as well.</p>