在Matplotlib中,参数在fig.add_subplot(111)中意味着什么?有时我遇到这样的代码:import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]y = [1, 4, 9, 16, 25]fig = plt.figure()fig.add_subplot(111)plt.scatter(x, y)plt.show()哪个产生:我一直在疯狂阅读文档,但我无法找到解释111。有时我看到了212。这个论点fig.add_subplot()意味着什么?
3 回答

缥缈止盈
TA贡献2041条经验 获得超4个赞
这些是作为单个整数编码的子图网格参数。例如,“111”表示“1x1网格,第一个子图”,“234”表示“2x3网格,第4个子图”。
替代形式add_subplot(111)
是add_subplot(1, 1, 1)
。

倚天杖
TA贡献1828条经验 获得超3个赞
Constantin的答案很明显,但是对于更多背景,这种行为继承自Matlab。
Matlab行为在Matlab文档的图设置 - 显示每个图的多个图部分中进行了解释。
子图(m,n,i)将图窗口分成一个小的子图的m×n矩阵,并选择当前图的子图。绘图沿图形窗口的顶行编号,然后编号为第二行,依此类推。
添加回答
举报
0/150
提交
取消