title: saving multiple ggplots created in a for loop to a single plot
body: <p>I would like to have multiple ggplots plots in a single plot.
  ISSUE: When trying to create a list of plots (to be used later in grid.arrange) using a for-loop, the list is returned empty.<br>
  I used these two posts:</p>
  
  <p>1)<a href="https://stackoverflow.com/questions/26034177/r-saving-multiple-ggplots-using-a-for-loop">create figures in a loop</a><br>
  2)<a href="https://stackoverflow.com/questions/10706753/how-do-i-arrange-a-variable-list-of-plots-using-grid-arrange">use grid.arrange to save in a single fig</a></p>
  
  <p>to come up with the following code (simpler version)* to plot probability density curves:</p>
  
  <pre><code>#models = 33 obs of 1 variable
  plotlist = list()
  for (i in 1:33)
  {
   modname = models$col1[i]
   p&lt;- ggplot() + geom_line(aes(xi,yi)) + geom_line(aes(ai,bi)) + 
       ggtitle(modname) ## the x,y,a,b are just illustrative.
   #In reality, each pair is produced using fitdist and dgamma functions for
    # data (single column) from separate .csv
   ggsave(outpath)
   plotlist[[i]] = p   
  
  }
  main &lt;- grid.arrange(grobs=plotlist,ncol=6)
  main
  ggsave("bigplot.png",p)
  </code></pre>
  
  <p>ISSUE (further explanation): <code>plotlist</code> shows up as an empty list. As a result, grid.arrange just plots the subplot created in the last loop 33 times. But, what is strange is that the grid.arrange plot has the correct title for all subplots (assigned using modname)!!! In the attached picture, you will see that all subplots are the same except for the title. Since I save individual subplots as well, I know that the issue is not with the data/code for subplots. 
  <a href="https://i.stack.imgur.com/x21ng.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x21ng.png" alt="main"></a>
  I am fairly new to R and this is my first ggplot2 (* excuse the multiple geom_line()). As a result, it has taken me a while to figure out how to fit distributions and plot them (Thanks, stackoverflow!!) in the first place. So, any help here will be much appreciated. </p>
  
  <p>Update: I was able to accomplish the above using <strong><code>PIL</code> package in python</strong> . However, I would really like to be able to do this in R.</p>