title: Consistent color scale and legend between plots when not all levels of a grouping variable are present in the data
body: <p>I have data which is being sequentially added to a <code>data.frame</code> in R. I am creating plots every so often showing the results. The plot is colour coded according to certain criteria, some of which are never met, hence there is not this colour on the diagram. </p>
  
  <p>For example,</p>
  
  <pre><code>library(ggplot2)
  dates15=seq(as.POSIXct("2015-01-01 00:00:00"), as.POSIXct("2015-06-30 23:45:00"), by="15 min")
  ex.data=rnorm(length(dates15),2,1)
  blue=c(1:5000)
  pink=which(ex.data&gt;50)
  purple=c(10000:15000)
  colours=rep("Black points", length(dates15))
  colours[blue]="Blue Points"
  colours[pink]="Pink points"
  colours[purple]="Purple points"
  all.data=data.frame(Date=dates15, Data=ex.data, Colours=colours)
  g.cols=c("black", "blue", "pink", "purple")
  ggplot(all.data, aes(Date, Data, colour=Colours, group=1))+geom_line()+scale_color_manual(values=g.cols)+
    xlim(as.POSIXct("2015-01-01 00:00:00"), as.POSIXct("2015-02-12 23:45:00"))
  </code></pre>
  
  <p>In this example, I've set the variable pink to be points which are only greater than 50 (which is clearly not possible in my data). So when the plot is created, the '<code>Pink</code>' legend name is missing, but the colour pink has been assigned to the purple label. I would like the colours and labels to stay matched all the time, even if there is a variable which isn't used.</p>