Uneven drawing of subplot in matplotlib

If the sizes of the small pictures that I want to display are not the same, what should I do? Take the four small pictures above as an example, if the first small picture is placed in the first row, and the remaining three small pictures are placed in second line.

Use to plt.subplot(2,1,1)divide the entire image window into 2 rows and 1 column, and the current position is 1. Use plt.plot([0,1],[0,1])to create a small image at the first position.

plt.subplot(2,1,1)

Use to plt.subplot(2,3,4)divide the entire image window into 2 rows and 3 columns, and the current position is 4. Use plt.plot([0,1],[0,2])to create a small image at the 4th position.

plt.subplot(2,3,4)

Here I need to explain why the second small image is placed in the fourth position. In the previous step, plt.subplot(2,1,1)the entire image window was divided into 2 rows and 1 column. The first small image occupies the first position, which is the entire first row. In this step, plt.subplot(2,3,4)the entire image window is divided into 2 rows and 3 columns, so the first row of the entire image window becomes 3 columns, that is, 3 positions, so the first position of the second row is the entire image The fourth position of the window.

Use to plt.subplot(235)divide the entire image window into 2 rows and 3 columns, and the current position is 5. Use plt.plot([0,1],[0,3])to create a small image at the 5th position. Same as above, create again plt.subplot(236).

plt.subplot(235)

plt.subplot(236)

plt.show()  # 展示

Guess you like

Origin blog.csdn.net/weixin_40244676/article/details/104118970