Reputation: 5486
I try plot some time series in high quality but matplotlib fails to save the figures in high quality. In the plotting the output looks like in the picture below, which is a screenshot.
But using plt.safefig() or the save button gives me the following result
The core of the problem is that I have to save plots using the png-backend. Safing as pdf, a file is created, which can not be opened by other apps. Even though the files are < 500 kb. The same happens when safing as .eps. My code is like:
fig = plt.figure(1, figsize=(10, 6))
ax = fig.add_subplot(111, autoscale_on=True, ylim=(-1,1))
ax.plot(sig_obj, '-k', alpha=.3)
# plot of vertical lines ...
plt.savefig('figure_1.png') # or .pdf
where sig_obj
is an array of length > 350000. Using Python 3.4 and matplotlib 1.3.3 on OS X 10.9.4.
Does anyone have an idea to improve my plot quality?
Upvotes: 2
Views: 5748
Reputation: 13467
You can either set a high dpi for a raster image:
savefig("1.png", dpi=600)
or save it in a vector format:
savefig("1.svg") # or: "1.pdf" (depending on a backend)
Upvotes: 7