subplot(m,n,i) breaks the figure window into an m-by-n matrix of small
subplots and selects the ithe subplot for the current plot. The plots
are numbered along the top row of the figure window, then the second
row, and so forth.
import matplotlib.pyplot as plt
fig = plt.figure()
fig.add_subplot(221) #top left
fig.add_subplot(222) #top right
fig.add_subplot(223) #bottom left
fig.add_subplot(224) #bottom right
plt.show()
康斯坦丁的答案是正确的,但是对于更多的背景,这个行为是从Matlab继承的。
在Matlab文档的Figure Setup - Displaying Multiple Plots per Figure部分中解释了Matlab的行为。
这些是编码为单个整数的子块网格参数。例如,“111”表示“1x1网格,第一子块”,“234”表示“2x3网格,第四子块”。
add_subplot(111)
的替代形式是add_subplot(1, 1, 1)
。我想这最好用下面的图片来解释:
要初始化上述内容,可以键入:
相关问题 更多 >
编程相关推荐