Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving plot with high resolution image [duplicate]

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?

like image 327
Roopa Avatar asked Nov 14 '17 10:11

Roopa


People also ask

How do I save an Excel graph as a high resolution image?

Copy the graph in Excel (CTRL+C) and paste into PowerPoint as a Microsoft Excel object. (The PPT slide size should be set to match the size of the graph using the Slide Size option in the Design tab). From there, right-click on the slide, select “Save as Picture”, and then use the PNG file format option.

How do I save a high resolution plot in Matlab?

To save a figure as an image at a specific resolution, call the exportgraphics function, and specify the 'Resolution' name-value pair argument. By default, images are saved at 150 dots per inch (DPI). For example, create a bar chart and get the current figure. Then save the figure as a 300-DPI PNG file.

How do I save a high resolution plot in Python?

To save the file in pdf format, use savefig() method where the image name is myImagePDF. pdf, format="pdf". We can set the dpi value to get a high-quality image. Using the saving() method, we can save the image with format=”png” and dpi=1200.


2 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.

like image 108
Eamonn Kenny Avatar answered Sep 22 '22 06:09

Eamonn Kenny


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.

like image 38
Vasyl Lyashkevych Avatar answered Sep 26 '22 06:09

Vasyl Lyashkevych