Code Yarns ‍👨‍💻

How to change DPI in Matplotlib

(First posted on: 2015-07-29 12:13:00+00:00)

Matplotlib can be used to output plot to PNG image files. To render for this bitmap format, Matplotlib uses a default DPI of 100. This is a surprisingly low DPI for plots. Thankfully, the DPI can be changed easily.

using matplotlib.pyplot as mplot
mplot.savefig("foo.png", dpi=300)
savefig.dpi: 300

Tried with: Matplotlib 1.4.3, Python 2.7.6 and Ubuntu 14.04