- 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 reuse plots in Matplotlib?
To reuse plots in Matplotlib, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create a new figure or activate an existing figure using figure() method.
- Plot a line with some input lists.
- To reuse the plot, update y data and the linewidth of the plot
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True line, = plt.plot([1, 3], [3, 4], label="line plot", color='red', lw=0.5) line.set_ydata([3.5]) line.set_linewidth(4) plt.show()
Output
- Related Articles
- How to add annotations in Matplotlib Plots?
- How to save Matplotlib 3d rotating plots?
- How to make semilogx and semilogy plots in Matplotlib?
- How to plot half or quarter polar plots in Matplotlib?
- How to get multiple overlapping plots with independent scaling in Matplotlib?
- How to clear the memory completely of all Matplotlib plots?
- How to animate a time-ordered sequence of Matplotlib plots?
- How to merge two existing Matplotlib plots into one plot?
- Fixing color in scatter plots in Matplotlib
- How can Matplotlib be used to create multiple plots iteratively in Python?
- How to display print statements interlaced with Matplotlib plots inline in iPython?
- Drawing lines between two plots in Matplotlib
- Embedding small plots inside subplots in Matplotlib
- Logscale plots with zero values in Matplotlib
- How to align multiple plots in a grid using GridSpec Class in Matplotlib

Advertisements