Well, if you are going to put all the SEPARATE graphics on the same screen, this is possible with the gridExtra package. However, depending on the situation, there is the feature of the facets or also put all the curves on the same chart. Let's go to each case:
1) Separate graphics on the same screen
library(gridExtra)
p1 <- ggplot(mtcars, aes(mpg, cyl)) + geom_point()
p2 <- ggplot(mtcars, aes(mpg, cyl)) + geom_line()
p3 <- ggplot(mtcars, aes(mpg, cyl)) + geom_line(color="blue")
p4 <- ggplot(mtcars, aes(mpg, cyl)) + geom_line(color="red")
grid.arrange(p1,p2, p3, p4)
2)Toshowthecaseusingfacets,Iwillusethetipsdatasetfromthereshape2package
library(tips)library(ggplot2)data(tips)head(tips)total_billtipsexsmokerdaytimesize116.991.01FemaleNoSunDinner2210.341.66MaleNoSunDinner3321.013.50MaleNoSunDinner3423.683.31MaleNoSunDinner2524.593.61FemaleNoSunDinner4625.294.71MaleNoSunDinner4
Seethatwehavethevalueofthebill,thetip,thesex,howthedaywas,andsoon.SupposeIwanttoseetherelationshipbetweenthebillandthefractionofthetipinrelationtotheaccount:
g1<-ggplot(tips,aes(x=total_bill,y=tip/total_bill))+geom_point(shape=1)
Let's use the facets and present the same chart, only by separating by gender, that is, we will see who gives the most tip in relation to the value of the account, men or women.
g1 + facet_grid(. ~ sex)
3)Finally,let'sputallthecurvesinthesamegraph.Stillusingthesamedatasettipsandusingasmoothingfunction.
ggplot(tips,aes(x=total_bill,y=tip/total_bill,fill=sex,col=sex))+geom_point(shape=1)+geom_smooth()
The strategy to be used, 1), 2) or 3) depends on each particular case.