04 Use of subplot in Python Matplotlib library

The #subplot () function divides the canvas into areas and draws the chart on the specified area of ​​the canvas

x = np.linspace(0, 10, 100)

# 将画布分为2行2列,将图画到画布的1区域
plt.subplot(2, 2, 1)  #subplot(行, 列, 要放置的区域) 
plt.xlim(-5, 20)  # 修改x轴的坐标值范围
plt.ylim(-5, 20)  # 修改y轴的坐标值范围
sin_y = np.sin(x)
plt.plot(x, sin_y)

plt.subplot(2, 2, 4)
cos_y = np.cos(x)
plt.plot(x, cos_y)

plt.show()
Published 36 original articles · praised 0 · visits 628

Guess you like

Origin blog.csdn.net/Corollary/article/details/105391512