title: Avoid reordering the legend alphabetically in ggplot2
body: <p>I made the following code, which reads a table (with 10 columns) and generates a line graph. The problem is, it reorders the legend alphabetically. How to avoid reordering and keep the original ordering? I already read how to avoid it by removing the <code>breaks</code> but I could not sort it out.</p>
  
  <p>Any idea would be great.</p>
  
  <p>Appreciate! </p>
  
  <p><code>qw</code> is a dataframe.</p>
  
  <pre><code>qw %&gt;% 
    add_rownames() %&gt;% 
    gather(reading, value, -rowname) %&gt;% 
    group_by(rowname) %&gt;% 
    mutate(x=1:n()) %&gt;% 
    ggplot(aes(x=x, y=value, group=rowname)) +
    geom_line(aes(color=rowname), line = 2.5, cex = 1.05) + 
    labs(colour= "Methods",x="XXXX", y="YYYY") + 
    theme(axis.text=element_text(size=14), 
          axis.title=element_text(size=14)) + 
    xlim(min=1, max=10)+ 
    scale_x_continuous(breaks=c(1,2,3,4,5,6,7,8,9,10)) + 
    theme(legend.text=element_text(size=12)) + 
    geom_point() 
  </code></pre>