- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- 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

To combine several matplotlib axes subplots into one figure, we can use **subplots()** method with **nrow=2.**

- Set the figure size and adjust the padding between and around the subplots.
- Create
**x**,**y1**and**y2**data points using numpy. - Create a figure and a set of subplots.
- Plot
**x,****y1**and**y2**data points using**plot()**method. - To display the figure, use
**show()**method.

import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-10, 10, 100) y1 = np.sin(x) y2 = np.cos(x) fig, axes = plt.subplots(nrows=2) line1, = axes[0].plot(x, y1, color='red') line2, = axes[1].plot(x, y2, color='green') plt.show()

- Related Questions & Answers
- How to make more than 10 subplots in a figure using Matplotlib?
- How to annotate several points with one text in Matplotlib?
- Annotate Subplots in a Figure with A, B, C using Matplotlib
- What is the preferred way to set Matplotlib figure/axes properties?
- How to show multiple images in one figure in Matplotlib?
- How to share x axes of two subplots after they have been created in Matplotlib?
- How to display multiple images in one figure correctly in matplotlib?
- How do I show the same Matplotlib figure several times in a single IPython notebook?
- How to programmatically add buttons into a layout one by one in several lines in Android
- How to switch axes in Matplotlib?
- How should I pass a matplotlib object through a function; as Axis, Axes or Figure?
- How do I programmatically add buttons into layout one by one in several lines using Kotlin?
- How to zoom subplots together in Matplotlib/Pyplot?
- How to remove a frame without removing the axes tick labels from a Matplotlib figure in Python?
- What is the difference between drawing plots using plot, axes or figure in matplotlib?

Advertisements