matplotlib画线plot

概述

本文讲解使用plot()画折线图

官方文档:
https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html?highlight=plot#matplotlib.pyplot.plot

语法

matplotlib.pyplot.plot(x,y,**kwargs)
参数

例子:绘制一天气温变化图

网址:
http://www.weather.com.cn/weather1d/101060101.shtml#input

import matplotlib.pyplot as plt

temps=[23,22,23,24,27,28,25,23]
hours=list(range(2,26,3))
print(temps)
print(hours)

plt.plot(hours,temps)
# 显示
plt.show()

执行结果如下图:


原文出处:/show_1EF3n1dimHwP.html