I have produced a large number of plots using a looped bit of ggplot code (below) which saves to disk as discrete images. I would like to produce panel plots showing several of these images as one.
Had I produced the plots manually, I would name them and then call par(mf) or similar to lay them out as desired. However, I can't find an alternative that works within (or after) my loop.
*
graph <- function(MONTH_13, na.rm=TRUE) {
SITE_LIST <- unique(MONTH_13$SITE_NUMB)
for(i in seq_along(SITE_LIST)){
plotA <- ggplot(subset(MONTH_13, MONTH_13$SITE_NUMB==SITE_LIST[i]), aes(HR, OXYCONC, colour=VIAL_ID)) +
geom_point(size=2) +
geom_smooth(method="lm", se= FALSE)+
labs(x="HR", y="OXY") +
labs(title= SITE_LIST[i]) +
theme(legend.position="top") +
scale_color_brewer(name="VIAL #", palette="Dark2") +
ylim(0, 400) +
xlim(0, 200)
ggsave(plotA, file=paste('/Users/stafel/Desktop/MONTH_13/Site_', SITE_LIST[i], ".png", sep=''), scale=2)
print(plotA)}}
graph(MONTH_13)
*
The above code will produce 13 plots. I want to put all 13 of these onto one panel plot image.
Many thanks for any help!