我想使用 Python matplotlib 创建包含许多 (100) 个子图的图。我找不到合适的语法:
我想要类似的东西(这不起作用)
plt.subplot(10,10,i,X1, Y)
在 i 从 0 到 99 的循环中,然后
plt.show()
语法在许多教程中都可用,以应对只有少数子图的情况。然后,语法可以是
plt.close('all')
fig = plt.figure()
ax1 = plt.subplot(221)
ax2 = plt.subplot(223)
ax3 = plt.subplot(122)
example_plot(ax1)
example_plot(ax2)
example_plot(ax3)
plt.tight_layout()
对于我的问题,我想我不能使用相同的语法,因为我会使用 plt.subplot(10101)
等,我不明白。
你有解决办法吗?
谢谢
最佳答案
试试这个:
fig, ax = plt.subplots(10, 10)
其中 ax 将在(列表的)列表中包含一百个轴。
这是一个非常方便的功能,来自 the docs :
Definition: plt.subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True, subplot_kw=None, **fig_kw)
Create a figure with a set of subplots already made.
This utility wrapper makes it convenient to create common layouts of
subplots, including the enclosing figure object, in a single call.
关于python - 使用 matplotlib 的大量子图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13365617/