如何使用 Matplotlib 显示两个数字?


我们可以使用 plt.figure() 方法创建图形,然后通过传递字符串作为参数来设置它们的标题。

步骤

  • 创建新图形,或激活现有图形(窗口标题为“Welcome to figure 1”)。

  • 使用 plot() 方法在当前图形上绘制线条。

  • 创建新图形,或激活现有图形(窗口标题为“Welcome to figure 2”)。

  • 使用 plot() 方法在当前图形上绘制线条。

  • 使用 plt.show() 显示图形。

示例

from matplotlib import pyplot as plt

plt.figure("Welcome to figure 1")
plt.plot([1, 3, 4])
plt.figure("Welcome to figure 2")
plt.plot([11, 13, 41])

plt.show()

输出结果

更新于: 2021 年 3 月 16 日

9K+ 次浏览

开启您的职业生涯

完成课程获得认证

开始学习
广告
© . All rights reserved.