Matplotlib Pyplot
Pyplot
大多数 Matplotlib 绘图功能位于 pyplot 子模块下,通常以 plt 的别名导入:
import matplotlib.pyplot as plt
现在,Pyplot 包可以称为 plt。
实例
在图表中从位置(0,0)到位置(6,250)绘制一条线:
import sysimport matplotlibmatplotlib.use('Agg')import matplotlib.pyplot as pltimport numpy as npxpoints = np.array([0, 6])ypoints = np.array([0, 250])plt.plot(xpoints, ypoints)plt.show()plt.savefig(sys.stdout.buffer)sys.stdout.flush()
结果:

在接下来的章节中,您将了解有关绘制(绘图)的更多知识。