matplotlib是python的一个绘图库
安装matplotlib
python -mpip install -U pip
python -mpip install -U matplotlib
创建简单的Plot
引入类库
import matplotlib.pyplot as plt
import numpy as np
创建数据
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
创建plot,并填充数据
fig, ax = plt.subplots()
ax.plot(t, s)
设置plot标签
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()
显示图像
plt.show()
保存图片
fig.savefig("test.png")