- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to plot a high resolution graph in Matplotlib?
We can use the resolution value, i.e., dots per inch, and the image format to plot a high-resolution graph in Matplotlib.
Steps
Create a dictionary with Column 1 and Column 2 as the keys and Values are like i and i*i, where i is from 0 to 10, respectively.
Create a data frame using pd.DataFrame(d); d created in step 1.
Plot the data frame with ‘o’ and ‘rx’ style.
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.
To show the image, use the plt.show() method.
Example
import pandas as pd from matplotlib import pyplot as plt d = {'Column 1': [i for i in range(10)], 'Column 2': [i * i for i in range(10)]} df = pd.DataFrame(d) df.plot(style=['o', 'rx']) resolution_value = 1200 plt.savefig("myImage.png", format="png", dpi=resolution_value) plt.show()
Output
- Related Articles
- How to manage image resolution of a graph in Matplotlib
- How to plot a line graph from histogram data in Matplotlib?
- How to plot a bar graph in Matplotlib from a Pandas series?
- How to show a bar and line graph on the same plot in Matplotlib?
- Plot a Line Graph for Pandas Dataframe with Matplotlib?
- How to plot a graph in Python?
- How to create a high resolution timer with C++ and Linux?
- How to change the resolution of a plot in base R?
- How to a plot stem plot in Matplotlib Python?
- How can matplotlib be used to plot 3 different datasets on a single graph in Python?
- How to plot multiple Pandas columns on the Y-axis of a line graph (Matplotlib)?
- Plot multiple boxplots in one graph in Pandas or Matplotlib
- How to plot a circle in Matplotlib?
- How to plot a watermark image in Matplotlib?
- How to animate a line plot in Matplotlib?

Advertisements