本博文源于绘图基础,主要讲解如何用python的plot绘制气温的折线图。先讲解plot参数如何使用后给出一个气温折线图样例绘制

使用plot()绘制折线图
plot(x,y,fmt,scalex=True,data=None,label=None,*args,**kwargs)
该函数常用参数的含义如下:
实例1:未来15天最高气温和最低气温
| 日期 | 最高气温 | 最低气温 |
|---|---|---|
| 9月4日 | 32 | 19 |
| 9月5日 | 33 | 19 |
| 9月6日 | 34 | 20 |
| 9月7日 | 34 | 22 |
| 9月8日 | 33 | 22 |
| 9月9日 | 31 | 21 |
| 9月10日 | 30 | 22 |
| 9月11日 | 29 | 16 |
| 9月12日 | 30 | 18 |
| 9月13日 | 29 | 18 |
| 9月14日 | 26 | 17 |
| 9月15日 | 23 | 14 |
| 9月16日 | 21 | 15 |
| 9月17日 | 25 | 16 |
| 9月18日 | 31 | 16 |
实验效果
实验代码
import matplotlib.pyplot as plt import numpy as np x = np.arange(4,19) y_max = np.array([32,33,34,34,33,31,30,29,30,29,26,23,23,25,31]) y_min = np.array([19,19,20,22,22,21,22,16,18,18,17,14,15,16,16]) # 绘制折线图 plt.plot(x,y_max) plt.plot(x,y_min) plt.show()