I've got a function that produces a plot, which I run six times. I want to extract each plot, then draw one multi-panel plot with each plot and only one legend.
I've tried using the assign function, along with return, to extract my plots, but I can't seem to get it to work.
My code:
levels = c('Genus','Family','Order','Class','Phylum','Domain')
Taxon_senPrec_func = function(x){
df = subset(d, Taxonomic_level == x)
q=ggplot(df, aes(x=Sensitivity, y=Precision, col=Database, shape=ID_cutoff)) +
geom_point(size=3) +
ggtitle(
paste('The ',x,' sensitivity and precision of various annotation techniques.',
sep='')) +
ylim(0,100) +
xlab('Sensitivity (%)') +
ylab('Precision (%)') +
scale_shape_manual(values=1:9)
p = assign(paste("plot_",x,sep=""), q)
return(p)
}
for(level in levels){
Taxon_senPrec_func(level)
}