matplotlib中超过9个子图

53 投票
3 回答
30905 浏览
提问于 2025-04-16 06:55

在matplotlib中,能不能创建超过9个子图?

我正在使用子图命令 pylab.subplot(449);,我该怎么才能让 4410 这个数字有效呢?

非常感谢!

3 个回答

0

你也可以这样做:

import matplotlib.pyplot as plt

N = 10 # number of subplots you want
fig, axes = plt.subplots(nrows = N)

这样一来,len(axes) = N,这就意味着你会有一个轴(坐标轴)来对应每个子图,方便你进行操作。

8

你也可以用pyplot这样做:

import matplotlib.pyplot as plt
oFig1 = plt.figure(1)

oFig1.add_subplot(4,4,11)      #(m,n,x) -> x starts with 1
...
74

这比我想象的要简单,我只需要输入:pylab.subplot(4,4,10),然后就成功了。

撰写回答