Saving plot with high resolution image

Viewed 18005

Since, i'm a newbie to python. I was trying to save a plot using matplotlib in python with the command plt.savefig(). The problem is that the image being save is low in resolution. Unable to read data points.

I was wondering if there is a way to save such figures in a very high resolution?

3 Answers

Use a resolution that uses specific sizing that is large :

 fig = plt.figure(figsize=(19.20,10.80))

produces 1080p for example and you can go much higher than this.

You can use savfig() to export to an image file with specification of the dpi:

import matplotlib.pyplot as plt
...
plt.savefig('plot_name.png', dpi = 300)

You can choose needed dpi by yourself. I hope it will be useful for you.

savefig(fname, dpi=None, facecolor='w', edgecolor='w',
    orientation='portrait', papertype=None, format=None,
    transparent=False, bbox_inches=None, pad_inches=0.1,
    frameon=None)

you can use dpi=300 or other values

Related