python subplots循环画图

https://jakevdp.github.io/PythonDataScienceHandbook/04.08-multiple-subplots.html

plt.subplots()

 ## axes are in a two-dimensional array, indexed by [row, col]
fig, ax = plt.subplots(2, 3, sharex='col', sharey='row')
for i in range(2):
    for j in range(3):
        ax[i, j].text(0.5, 0.5, str((i, j)),
                      fontsize=18, ha='center')

In comparison to plt.subplot(), plt.subplots() is more consistent with Python's conventional 0-based indexing.

python subplots循环画图_第1张图片

plt.subplot()

for i in range(1, 7):
    plt.subplot(2, 3, i)
    plt.text(0.5, 0.5, str((2, 3, i)),
             fontsize=18, ha='center')

python subplots循环画图_第2张图片

你可能感兴趣的:(Python)