- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 make several plots on a single page using Matplotlib?
We can create a figure using plt.figure() method and can create axes using fig.add_subplot(211) where nrow=2 and ncols=1. After that, we can plot the lines over both the plots in a figure.
Using gcf() method, Get the current figure. If no current figure exists, a new one is created using `~.pyplot.figure()`.
Add an `~.axes.Axes` to the figure as part of a subplot arrangement, using add_subplot() method, where nrows = 2, ncols = 1 and position = 1.
Plot the line using plt.plot() method at position 1.
Add an `~.axes.Axes` to the figure as part of a subplot arrangement, using add_subplot() method, where nrows = 2, ncols = 1 and position = 2.
Plot the line using plt.plot() method at position 2.
To show the figure use plt.show() method.
from matplotlib import pyplot as plt fig = plt.figure() ax1 = fig.add_subplot(211) ax1.plot([(1, 2), (3, 4)]) ax2 = fig.add_subplot(212) ax2.plot([(7, 2), (5, 3)]) plt.show()
- How to make several plots on a single page using Matplotlib(Python)?
- How to make several plots on a single page using matplotlib in Python?
- How to make semilogx and semilogy plots in Matplotlib?
- How to make several legend keys to the same entry in Matplotlib?
- How to make a page redirect using jQuery?
- How do I show the same Matplotlib figure several times in a single IPython notebook?
- How to make two plots side-by-side using Python?
- How to reuse plots in Matplotlib?
- How to make page links in HTML Page?
- How to Join Several Partitions on Linux
- How to make markers on lines smaller in Matplotlib?
- How to add annotations in Matplotlib Plots?
- How to save Matplotlib 3d rotating plots?
- How to align multiple plots in a grid using GridSpec Class in Matplotlib
- Adding a legend to a Matplotlib boxplot with multiple plots on the same axis