I am trying to add an extra line which contains less points.
I have tried:
library(ggplot2)
df <- data.frame(x=c(1:50),y=c(1:50)*2+5)
df2 <- data.frame(x=c(20,30,40),y=c(40,60,80))
plot1 <- ggplot(df , aes(x=x, y=y)) + geom_line()
plot2 <- plot1+ geom_line( aes(x=df2$x, y=df2$y))
plot2
But this does not work.
You could pass
df2to thedataargument of the secondgeom_linecall and change the mapping slightly