title: Multiple matplotlib plots in reportlab
body: <p>I'm trying to put a matplotlib graph onto a reportlab canvas. I can do a simple graph with the code from this question: <a href="https://stackoverflow.com/questions/18897511/how-to-drawimage-a-matplotlib-figure-in-a-reportlab-canvas">How to drawImage a matplotlib figure in a reportlab canvas?</a>
  But when I try to use subplots or use multiple plots it will not work properly. Doing it this way causes the same image to be plotted twice even when I added things like imgdata.close() or deleting the figure:</p>
  
  <pre><code>    from matplotlib.figure import Figure
      import cStringIO
      from reportlab.pdfgen import canvas
      from reportlab.lib.utils import ImageReader       
  
      can = canvas.Canvas()
      self.f = Figure()
      plot(x,y)
      xlabel(xlbl)
      ylabel(ylbl)
  
      imgdata=cStringIO.StringIO()
      savefig(imgdata,format='png')
      imgdata.seek(0)
      Image = ImageReader(imgdata)
      can.drawImage(Image,100,250, width=400,height=350)
  
      self.g = Figure()
      plot(x,y)
      xlabel(xlbl)
      ylabel(ylbl)
  
      secondimgdata = cStringIO.StringIO()
      savefig(secondimgdata,format='png')
      secondimgdata.seek(0)
  
      Image2 = ImageReader(secondimgdata)
      can.drawImage(Image2,100,150, width=400,height=350)
  </code></pre>
  
  <p>When trying with subplots it simply produces a blank graph and I did not know where to go with it:</p>
  
  <pre><code>    self.f = Figure()
      self.a = self.f.add_subplot(111)
      self.a.plot(x,y)
      self.a2 =self.a.twinx()
      self.a2.plot(x,y2,'r')
      self.a2.set_ylabel(ylbl2)
      self.a.set_xlabel(xlbl)
      self.a.set_ylabel(ylbl)
  </code></pre>
  
  <p>Any solution or advice to this problem would be very much appreciated.</p>