# How to plot in multiple subplots

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to plot in multiple subplots in Python. So Here I am Explain to you all the possible Methods here.

## How to plot in multiple subplots?

1. How to plot in multiple subplots?

You might be interested in the fact that as of matplotlib version 2.1 the second code from the question works fine as well.

2. plot in multiple subplots

You might be interested in the fact that as of matplotlib version 2.1 the second code from the question works fine as well.

## Method 1

There are several ways to do it. The `subplots` method creates the figure along with the subplots that are then stored in the `ax` array. For example:

```import matplotlib.pyplot as plt

x = range(10)
y = range(10)

fig, ax = plt.subplots(nrows=2, ncols=2)

for row in ax:
for col in row:
col.plot(x, y)

plt.show()
```

However, something like this will also work, it’s not so “clean” though since you are creating a figure with subplots and then add on top of them:

```fig = plt.figure()

plt.subplot(2, 2, 1)
plt.plot(x, y)

plt.subplot(2, 2, 2)
plt.plot(x, y)

plt.subplot(2, 2, 3)
plt.plot(x, y)

plt.subplot(2, 2, 4)
plt.plot(x, y)

plt.show()
```

## Method 2

You might be interested in the fact that as of matplotlib version 2.1 the second code from the question works fine as well.

Figure class now has subplots method The Figure class now has a subplots() method which behaves the same as pyplot.subplots() but on an existing figure.

Example:

```import matplotlib.pyplot as plt

fig = plt.figure()
axes = fig.subplots(nrows=2, ncols=2)

plt.show()```

## Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.