首页 > 技术文章 > matplotlib添加子图

chentianyu 2022-01-06 13:55 原文

import matplotlib.pyplot as plt
fig=plt.figure(figsize=[20,9])#设置图像宽高
fig1 = fig.add_subplot(1,2,1)###1行2列,处于第1个位置
fig2 = fig.add_subplot(1,2,2)
fig1.plot(test_list[0]['today_tmp'],label="today_tmp",color="#F08080")
fig2.plot(test_list[0]['nextday'],label="nextday",color="#0000FF")
plt.legend()#显示图例,如果注释改行,即使设置了图例仍然不显示
plt.show()#显示图片,如果注释改行,即使设置了图片仍然不显示

推荐阅读