
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Save Image for Maximized Window in Matplotlib using Pylab Savefig
To save image for maximized window instead of default size, we can use the following Steps −
Create figure with figsize=(7.50, 3.50), using the figure() method.
Plot the lines using the plot() method with list, color=”red”, and linewidth=2.
Save the figure using the savefig() method.
To display the figure, use the show() method.
Example
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() plt.plot([1, 3, 7, 3, 1], c="red", lw=2) plt.savefig("full_image.png") plt.show()
Output
Advertisements