I created the following graph in R using ggplot2. As you can see, the order in the legend is not exactly what it should be: I would like to have \"
R
ggplot2
It's changing names into a factor variable and using alphabetical order by default
use
df$names <- factor(df$names, levels = c("1 year","4 years","15 years","25 years","40 years"))