I am generating a figure using the PS backend:
import matplotlib
matplotlib.use('ps')
from matplotlib import pyplot as plt
plt.plot((1, 2))
I would like to save the figure:
plt.savefig('test.eps', format='eps', bbox_inches='tight', pad_inches=1.0)
Incidentally, I will make a PNG out of it later (in case it turns out to be relevant to the solution):
gs -q -dSAFER -dBATCH -dNOPAUSE -dUseTrimBox -dEPSCrop -sDEVICE=pngalpha -sOutputFile=test.png test.eps
The result is (PNG viewed in eog
):
I would like to change the size of the EPS or the PNG figure, but adding a dpi
kwarg to savefig
does not change the output. Calling plt.gcf().set_size_inches(10, 10)
does nothing as well. How do I make my EPS or PNG file have a higher resolution?
This answer is relevant in that it hints that setting dpi
for the ps
backend may not be the way to go.
Update
For clarification, it is necessary for me to use the PS backend. At the moment, it is the only one that correctly renders LaTeX colored strings. PGF may or may not do what I want, but I do not have time to research its quirks in depth. I was able to get a hacky solution by adding a -r...
argument to gs
, but would prefer to control everything from MatPlotLib.