0

With savefig('foo.pdf') or savefig('foo.png'), it seems like we can only plot one thing to one file (foo.png or foo.pdf) at a time. Is there a way to plot multiple images to the same file, one after another?

I need something like this:

for center in centers:
    plt.imshow(center.reshape(28, 28))
    plot/save this current image to file, all in the same file

So I just want all of the reshaped, 28 by 28 images contained in the centers list in the same file. For many months, I've had to plt.show() each image, take screenshots of those individual images, and then crop and paste them into one file. But this obviously doesn't scale.

Sнаđошƒаӽ
  • 16,753
  • 12
  • 73
  • 90
Jobs
  • 3,317
  • 6
  • 26
  • 52
  • 2
    Typically we would use [`subplot`](http://matplotlib.org/examples/pylab_examples/subplot_demo.html) for that. – Suever Apr 30 '16 at 23:46

1 Answers1

1

If you want several images on one page, you're looking for plt.subplots, Why do many examples use "fig, ax = plt.subplots()" in Matplotlib/pyplot/python

If you want a multipage PDF document, there's PDF backend: http://matplotlib.org/examples/pylab_examples/multipage_pdf.html

Community
  • 1
  • 1
ev-br
  • 24,968
  • 9
  • 65
  • 78