python - 使用 matplotlib 的大量子图

标签 python graphics plot matplotlib subplot

我想使用 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()

code is from here .

对于我的问题,我想我不能使用相同的语法,因为我会使用 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/

相关文章:

algorithm - 如何平滑 3D 体素世界的 block ?

c++ - OpenGL 纹理未显示

c++ - 三角立方体/体素交集

Perl:将(x,y)像素绘制到单色位图的推荐方法

r - 如何删除 ggsurvplot 图例中的自动 "strata"-text?

python - Bokeh (Python): Format DateTime in Hover tooltip

python - App Engine NDB 简单创建读取更新

python - concurrent.futures 的状态并未反射(reflect)其真实状态

mysql - 使用 PyMySQL 的列顺序错误的 SELECT 结果

matlab - 我应该如何更新 Matlab 中绘图的数据?