

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Saving images in Python at a very high quality
To save the images in Python with very high quality, you need to follow the steps given below −
Create fig and ax variables using subplots method, where default nrows and ncols are 1.
Plot the lines using plot() method.
We can add axes labels using ylabel() and xlabel().
To get a high-quality image, we can use .eps image format.
You can increase the dot per inch value, i.e., dpi.
Using savefig() method, we can save the image locally.
To show the figure, use plt.show().
Example
import matplotlib.pyplot as plt fig, ax = plt.subplots() plt.plot([0, 5], [0, 5]) plt.ylabel("Y-axis ") plt.xlabel("X-axis ") image_format = 'eps' # e.g .png, .svg, etc. image_name = 'myimage.eps' fig.savefig(image_name, format=image_format, dpi=1200)
Output
- Related Questions & Answers
- Top Twenty Sites with Free High Resolution Images
- How to talk to my neighbors who keep their TV volume very high?
- Saving a 3D-plot in a PDF 3D with Python
- Saving all the open Matplotlib figures in one file at once
- Differences between Quality Assurance and Quality Control
- How to handle very large numbers in Python?
- How to download all images on a web page at once?
- High-level file operations in Python (shutil)
- Working with Images in Python?
- Reading images using Python?
- Generating a movie from Python without saving individual frames to files
- I find it very difficult to wash blankets at home. What to do to clean them at home?
- How to compress Python objects before saving to cache?
- Python - Display images with PyGame
- Saving scatterplot animations with matplotlib
Advertisements