My code reads all the text file in the folder, turns it into an array and plots a histogram of each data using a for cycle, pretty simple stuf, but I want to save all it returns, all the histograms into a single pdf file. I know the function:
plt.savefig('file.pdf')
works but since it's in a for cycle it will only save the last one, I mean it overwrites on it. Is there a function to add the other histograms or should I change the code?
You essentially have two options.
1. Create multiple pdf files, merge them afterwards
2. Write all plots directly to a single pdf file.
Example from the matplotlib page: http://matplotlib.org/examples/pylab_examples/multipage_pdf.html
Output a Document (preferably a PDF) from Python
why does no picture show
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With