有时我会遇到这样的代码:
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()
的论点是什么意思?
有时我会遇到这样的代码:
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()
的论点是什么意思?
这些是编码为单个整数的子地块栅格参数.例如,"111"表示"1x1网格,第一个子地块","234"表示"2x3网格,第四个子地块".
add_subplot(111)
的替代形式是add_subplot(1, 1, 1)
.