I want to create four (largely identical) plots in R and combined into a single .png file to insert into a presentation.
I am using ggplot2.
I have to do a bit of data-wrangling first based on a single test value. Thus I have created a function (with the test value as the argument) and then assign the resulting figure to a figure object.
eg
Fig1 = RDDPlot('2010-05-02')
Fig2 = RDDPlot('2010-06-02')
Fig3 = RDDPlot('2010-07-02')
Fig4 = RDDPlot('2010-08-02')
I am trying to use par()
as per:
https://www.statmethods.net/advgraphs/layout.html
and
Multiple scatterplot figure in R
but all these example use plot and are done on a single line. I am building my plot up with multiple statements (eg combinations of scatterplot with vline, mean lines etc), so it is easier for me to assign to a figure object and then layout the objects in a (2,2).
The following does not work for me:
png(paste0(path,'Plot.png'),width=12.8,height=9.6,units="cm",res=1200)
par(mfrow=c(2,2))
Fig1
Fig2
Fig3
Fig4
dev.off()
It just produces a .png with only Fig1 on it...