以下是一个简单的 Python 程序,使用 Matplotlib 库的 pyplot 模块绘制三条曲线,并分别用不同颜色的实线表示:

import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y1 = [2, 4, 6, 8, 10]
y2 = [1, 3, 5, 7, 9]
y3 = [10, 8, 6, 4, 2]

plt.plot(x, y1, color='red')
plt.plot(x, y2, color='green')
plt.plot(x, y3, color='blue')

plt.show()

在这个程序中,我们首先导入了 Matplotlib 的 pyplot 模块。然后,我们定义三个列表 x、y1、y2 和 y3 来表示要绘制的三条曲线的 x 和 y 坐标值。接下来,我们使用 plot() 函数来绘制这三条曲线。在每个 plot() 函数调用中,我们指定了 x、y 坐标值和颜色。最后,我们调用 show() 函数来显示绘制的图形。

这个程序会生成一个简单的图形,其中包含三条曲线,每条曲线使用不同颜色的实线表示。

Python Matplotlib 绘制三条不同颜色曲线

原文地址: https://www.cveoy.top/t/topic/ne7o 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录