Let's say that I have two data frames defined in such way :
df <- data.frame(x=rep(1:3, 3), val=sample(1:100, 9),
variable='category')
df1 <- data.frame(x=rep(4:6, 3), val=sample(1:100, 9),
variable='category')
And I want to plot them both on one graph in such way that for x from 1 to 3 it would be the line, and for x from 4 to 6 it would be dots. So
plot_1<-ggplot(data=df,aes(x=x,y=val))+geom_line(aes(colour=variable))
plot_2<-ggplot(data=df1,aes(x=x,y=val))+geom_point(aes(colour=variable))
plot_grid(plot_1,plot_2,nrow = 1,ncol=1)
And in output I get the graph following :
So instead of line from 1 to 3 and dots from 4 to 6 I have just the first graph (line from 1 till 3).
Is there some easy way how to solve this problem ?