简单的折线图绘制
import matplotlib.pyplot as plt
import numpy as np #导入模块
x = np.arange(4, 19) #x轴数据
y_max = np.array([32, 33, 34, 34, 33, 31, 30, 29, 30, 29, 26, 23, 21, 25, 31]) #导入y轴数据
y_min = np.array([19, 19, 20, 22, 22, 21, 22, 16, 18, 18, 17, 14, 15, 16, 16])
fig = plt.figure() #创建类
ax = fig.add_subplot() #给画布fig上添加坐标系风格的绘图区域ax
ax.plot(x, y_max) #绘制气温最高气温线条
ax.plot(x, y_min) #绘制气温最低气温线条
plt.show() #展示图表