add subplot
时间: 2023-10-14 13:26:24 浏览: 75
Python使用add_subplot与subplot画子图操作示例
Sure, to add a subplot using Matplotlib in Python, you can use the `subplot()` function. For example, to add a subplot to a figure with 2 rows and 3 columns, you can use the following code:
```python
import matplotlib.pyplot as plt
# create the figure with 2 rows and 3 columns
fig, axs = plt.subplots(nrows=2, ncols=3)
# add a subplot to the first row and first column
axs[0, 0].plot([1, 2, 3], [4, 5, 6])
```
This will create a new subplot in the first row and first column of the figure. You can then customize the subplot as needed using the methods of the `Axes` object returned by the `subplot()` function.
阅读全文