I made a simple classic storyline with ggplot2 , which is two graphics in one. However, I am struggling to show the legend. This does not show the legend. I did not use the melt and redid the way, I just use the classic way. Below is my code.
df<-read.csv("testDataFrame.csv") graph<- ggplot(df,aes(A)) + geom_line(aes(y=res1), colour = "1")+ geom_point(aes(y=res1),size = 5,shape=12)+ geom_line(aes(y=res2), colour = "2")+ geom_point(aes(y=res2), size = 5, ,shape=20)+ scale_colour_manual(values=c("red","green"))+ scale_x_discrete (name="X axis")+ scale_y_continuous(name="Y-axis")+ ggtitle("Test")+ #scale_shape_discrete(name ="results",labels=c("Res1", "Res2"),solid = TRUE) print(graph)
data frame:
A,res1,res2 1,11,25 2,29,40 3,40,42 4,50,51 5,66,61 6,75,69 7,85,75
Any suggestion on how to show the legend for the above chart?
source share