- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Change figure size and figure format in Matplotlib
Using the figsize attribute of figure(), we can change the figure size. To change the format of a figure, we can use the savefig method.
Steps
Store the figure size in the variable.
Create a new figure, or activate an existing figure, with given figure size.
Plot the line using x.
Set the image title with its size.
Save the figure using savefig() method.
Example
from matplotlib import pyplot as plt figure_size = (10, 10) plt.figure(figsize=figure_size) x = [1, 2, 3] plt.plot(x, x) plt.title("Figure dimension is: {}".format(figure_size)) plt.savefig("imgae.png", format="png")
Output
- Related Articles
- How to set the matplotlib figure default size in ipython notebook?
- How to change the default path for "save the figure" in Matplotlib?
- Change figure window title in pylab(Python)
- How to position and align a Matplotlib figure legend?
- How to set the current figure in Matplotlib?
- How to retrieve colorbar instance from figure in Matplotlib?
- Matplotlib figure to image as a numpy array
- Exporting an svg file from a Matplotlib figure
- How to show multiple images in one figure in Matplotlib?
- How can multiple plots be plotted in same figure using matplotlib and Python?
- How to cycle through both colours and linestyles on a matplotlib figure?
- How to retrieve XY data from a Matplotlib figure?
- Save figure as file from iPython notebook using Matplotlib
- How to set the margins of a Matplotlib figure?
- How to convert Matplotlib figure to PIL Image object?

Advertisements