I create 2 plots, p1 and p10 and record them as follows:
plot(data$Fwd_EY, data$SPNom1YrFwdRet, pch = 16, cex = 1.0, col = "blue")
p1 <- recordPlot()
dev.off()
plot(data$Fwd_EY, data$SPNom10YrFwdRet, pch = 16, cex = 1.0, col = "blue")
p10 <- recordPlot()
dev.off()
I print P1 and P10 to .png files, and would then like to view both plots side by side before printing them to a single .png file. I have tried variants of the following with no success.
myPlots = c(p1, p10)
ggarrange(plotlist = myPlots, nrow = 1)
par(mfrow=c(1,2))
p1
p10
nf <- layout( matrix(c(1,2), ncol=1) )
p1
p10
In some cases, R seems to require the plots to be ggplots. In other cases the plots simply print full screen. How can I achieve my goal?
Thanks in advance
Thomas Philips