title: ggplot2: Missing legend when specify color using fill in geom_bar
body: <p>In the stacked bar chart, I am trying to specify the color for different bars. E.g, gradient green for treatment group and gradient blue for control group. However, after specifying the colors, I lost the legend. Is there a way to add legends back? </p>
  
  <pre><code># Create data set
  ID&lt;-c(rep(1:4, 6))
  Group&lt;-c(rep(0,4), rep(1,4), rep(0,4), rep(1,4), rep(0,4), rep(1,4))
  Time&lt;-c(rep("Time 1",8), rep("Time 2",8), rep("Time 3",8))
  Response&lt;-c(1,2,3,1,2,3,1,2,2,3,3,1,1,3,2,1,2,1,3,1,2,2,1,3)
  
  data &lt;- data.frame(ID, Group, Time, Response)
  data$Response&lt;-as.factor(data$Response)
  
  library(dplyr)
  data1&lt;-as.data.frame(
    data %&gt;% 
      group_by(Group, Time, Response) %&gt;%                     
      summarise(N= n()))
  
  # Define the color for control and treatment groups
  trtCol &lt;- c("#3182bd", "#9ecae1", "#deebf7")
  conCol &lt;- c("#31a354", "#a1d99b", "#e5f5e0")
  Palette&lt;-c(conCol, trtCol, conCol, trtCol, conCol, trtCol)
  
  library(ggplot2)
  library(scales)
  
  # Specify color in ggplot using "geom_bar (fill=Palette)"
  ggplot(data1, aes(Group, N, fill = Response))+ 
    geom_bar(position = "fill",stat = "identity", fill=Palette) + 
    facet_wrap(~Time, strip.position = "bottom") +
    labs(title="Distribution of Responses by Groups over Time", 
         x="Time Points", y="Percentage")+
    scale_y_continuous(labels = percent_format()) +
    theme_classic() +
    theme(plot.title = element_text(hjust = 0.5), 
          axis.text.x=element_blank(), axis.ticks.x=element_blank(), 
          panel.spacing = unit(0.1, "lines"))+
    geom_text(aes(x=0,y=-0.05,label="Control\nGroup"), size=3.5)+
    geom_text(aes(x=1,y=-0.05,label="Treatment\nGroup"), size=3.5)
  </code></pre>
  
  <p>When I specify the color for each bar, The legend disappeared.</p>
  
  <p><a href="https://i.stack.imgur.com/md5EQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/md5EQ.jpg" alt="plot 1"></a></p>
  
  <p><a href="https://i.stack.imgur.com/tlxRG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tlxRG.jpg" alt="plot2"></a></p>
  
  <p>The graph I want is shown above. Does anyone know how to get the legends back? One for treatment group and one for control group. Or is there a way to manually add legend?</p>