Matplotlib savefig into different pages of a PDF


Question

I have a lengthy plot, composed o several horizontal subplots organized into a column.

When I call fig.savefig('what.pdf'), the resulting output file shows all the plots crammed onto a single page.

Question: is there a way to tell savefig to save on any number (possibly automatically determined) of pdf pages?

I'd rather avoid multiple files and then os.system('merge ...'), if possible.

1
7
10/21/2012 2:29:37 AM

Accepted Answer

I haven't tried myself, but in the matplolib faq there are some instruction to save plots in pdf in several pages.

8
10/17/2012 4:53:06 PM

I suspect that there is a more elegant way to do this, but one option is to use tempfiles or StringIO to avoid making traditional files on the system and then you can piece those together.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon