04 Python Matplotlib 库中subplot的使用

#subplot()函数可将将画布分为区域,将图表绘制于画布的指定区域

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()
发布了36 篇原创文章 · 获赞 0 · 访问量 628

猜你喜欢

转载自blog.csdn.net/Corollary/article/details/105391512
今日推荐