Matplotlib pyplot.savefig() - Save an image and set the resolution in Matplotlib

The savefig() saves the image pyplot has created.

from matplotlib import pyplot

x = ['Fri', 'Sat', 'Sun']
y = [26, 31, 19]

pyplot.plot(x, y)

pyplot.savefig('sale.jpg')
pyplot.savefig('sale_2.jpg', dpi=50)

sale.jpg

sale_2.jpg (dpi=50)

The dpi option is the resolution of the saved image.

Comments

Powered by Markdown