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 breaks
but I could not sort it out.
Any idea would be great.
Appreciate!
qw
is a dataframe.
qw %>%
add_rownames() %>%
gather(reading, value, -rowname) %>%
group_by(rowname) %>%
mutate(x=1:n()) %>%
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()