Matplotlib Pyplot

Pyplot

Matplotlib 的大部分实用程序位于 pyplot 子模块下,并且通常使用 plt 别名导入:

import matplotlib.pyplot as plt

现在可以将 Pyplot 包称为 plt

实例

在图表中从位置 (0,0) 绘制一条线到位置 (6,250):

import matplotlib.pyplot as plt
import numpy as np

xpoints = np.array([0, 6])
ypoints = np.array([0, 250])

plt.plot(xpoints, ypoints)
plt.show()

亲自试一试

结果:

Matplotlib Pyplot

在接下来的章节中,您将学习更多关于绘图的内容。