Legend ordering in ggplot2
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 "4 years" coming after "1 year". I was wondering how this can be achieved. Source code: require("ggplot2") require("scales") # I have 5 data files containing two columns (x and y values) d1 = read.table("1yr.txt")$V2 d2 = read.table("4yr.txt")$V2 d3 = read.table("15yr.txt")$V2 d4 = read.table("25yr.txt")$V2 d5 = read.table("40yr.txt")$V2 rank1 = read.table("1yr.txt")$V1 rank2 = read.table("4yr.txt")$V1 rank3 = read.table("15yr.txt")$V1 rank4 = read