title: ggplot2: Fix colors to factor levels
body: <p>I'm working on a larger project for which I am creating several plots in ggplot2. The plots are concerned with plotting several different outcomes across several different discreet categories (think: countries, species, types). I would like to completely fix the mapping of discrete types to colors such that Type=A is always displayed in red, Type=B is always displayed in blue, and so on across all plots irrespective of what other factors are present. I know about <code>scale_fill_manual()</code> where I can provide color values manually and then work with <code>drop = FALSE</code> which helps in dealing with unused factor levels. However, I find this extremely cumbersome since every plot will need some manual work to deal with sorting the factors in the right way, sorting color values to match factor sorting, dropping unused levels, etc. </p>
  
  <p>What I am looking for is a way where I can map <em>once and globally</em> factor levels to specific colors (A=green, B=blue, C=red, ...) and then just go about plotting whatever I please and ggplot picking the right colors. </p>
  
  <p>Here is some code to illustrate the point.</p>
  
  <pre><code># Full set with 4 categories
  df1 &lt;- data.frame(Value = c(40, 20, 10, 60), 
                    Type = c("A", "B", "C", "D"))
  
  ggplot(df1, aes(x = Type, y = Value, fill = Type)) + geom_bar(stat = "identity")
  
  
  # Colors change complete because only 3 factor levels are present
  df2 &lt;- data.frame(Value = c(40, 20, 60), 
                    Type = c("A", "B", "D"))
  
  ggplot(df2, aes(x = Type, y = Value, fill = Type)) + geom_bar(stat = "identity")
  
  
  # Colors change because factor is sorted differently
  df3 &lt;- data.frame(Value = c(40, 20, 10, 60), 
                    Type = c("A", "B", "C", "D"))
  df3$Type &lt;- factor(df3$Type, levels = c("D", "C", "B", "A"), ordered = TRUE)
  
  ggplot(df3, aes(x = Type, y = Value, fill = Type)) + geom_bar(stat = "identity")
  </code></pre>