So I am trying to compile several dataframe in one graph. For my x value I have the number of days, and for y I have the frequency of something happening. My problem is that one of the dataframe (df3) ranges from 0 to 3, and the others from 0 to 50.
Dummy dataframes:
day<-c(1,2,3)
b<-c(23,44,22)
c<-c(12,35,49)
d<-c(1,1,3)
df1<-data.frame(day,b)
df2<-data.frame(day,c)
df3<-data.frame(day,d)
ggplot()+
geom_line(data=df1, aes(x=day, y=df1$`b`), color="red") +
geom_line(data=df2, aes(x=day, y=df2$`c` ), color="green")+
geom_line(data=df3, aes(x=day, y=df3$`d` ), color="blue")+
labs(x="Days", y="Number of occurrences")
This works fine, but I want to creat a diferent scale for df1 and df2, and another to df3.
UPDATE:
I am trying this, but it overwrites the previous scale:
d<-ggplot()+
geom_line(data=df1, aes(x=day, y=df1$`a`), color="red") +
geom_line(data=df2, aes(x=day, y=df2$`b` ), color="green")+
scale_y_continuous(limits=c(0, 50))+
labs(x="Days", y="Number of occurrences")
d+geom_line(data=df3, aes(x=day, y=df3$`c` ), color="blue")+
scale_y_continuous(limits=c(0, 3))