r-faq
Plot two graphs in a same plot
lines() or points() will add to the existing graph, but will not create a new window. So you’d need to do plot(x,y1,type=”l”,col=”red”) lines(x,y2,col=”green”)
Different legend-keys inside same legend in ggplot2
You can use override.aes= inside guides() function to change default appearance of legend. In this case your guide is color= and then you should set shape=c(NA,16) to remove shape for line and then linetype=c(1,0) to remove line from point. ggplot(df) + geom_line(aes(id, line, colour = “line”)) + geom_point(aes(id, points, colour = “points”))+ guides(color=guide_legend(override.aes=list(shape=c(NA,16),linetype=c(1,0))))