title: Order of factor levels changes when plotting layers with data subsets
body: <p>I am trying to control the order of items in a legend in a <code>ggplot2</code> plot in R. I looked up some other similar questions and found out about changing the order of the levels of the factor variable I am plotting. I am plotting data for 4 months, December, January, July, and June.</p>
  
  <p>If I just do one plot command for all the months, it works as expected with the months ordered in the legend appearing in the order of the levels of the factor. However, I need to have a different <code>dodge</code> value for the summer (June &amp; July) and winter (Dec &amp; Jan) data. I do this with two <code>geom_pointrange</code> commands. When I divide it into 2 steps, the order of the legend goes back to alphabetical. You can demonstrate by commenting out the "plot summer" or "plot winter" command.</p>
  
  <p>What can I change to keep my factor level order in the legend?  </p>
  
  <p>Please ignore the odd looking test data - the real data looks fine in this plot format.</p>
  
  <pre><code>#testdata
  hour &lt;- rep(seq(from=1,to=24,by=1),4)
  avg_hou &lt;- sample(seq(0,0.5,0.001),96,replace=TRUE)
  lower_ci &lt;- avg_hou - sample(seq(0,0.05,0.001),96,replace=TRUE)
  upper_ci &lt;- avg_hou + sample(seq(0,0.05,0.001),96,replace=TRUE)
  Month &lt;- c(rep("December",24), rep("January",24), rep("June",24), rep("July",24))
  
  testdata &lt;- data.frame(Month,hour,avg_hou,lower_ci,upper_ci)
  testdata$Month &lt;- factor(alldata$Month,levels=c("June", "July", "December","January"))
  
  #basic plot setup
  plotx &lt;- ggplot(testdata, aes(x = hour, y = avg_hou, ymin = lower_ci, ymax = upper_ci, color = Month, shape = Month))
  plotx &lt;- plotx + scale_color_manual(values = c("June" = "#FDB863", "July" = "#E66101",  "December" = "#92C5DE", "January" = "#0571B0"))
  
  #plot summer
  plotx  &lt;- plotx + geom_pointrange(data = testdata[testdata$Month == "June" | testdata$Month == "July",], size = 1, position=position_dodge(width=0.3)) 
  #plot winter
  plotx  &lt;- plotx + geom_pointrange(data = testdata[testdata$Month == "December" | testdata$Month == "January",], size = 1, position=position_dodge(width=0.6))
  
  print(plotx)
  </code></pre>