📌  相关文章
📜  如何在 python 绘图中添加图例 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:28.385000             🧑  作者: Mango

代码示例1
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 20, 1000)
y1 = np.sin(x)
y2 = np.cos(x)

plt.plot(x, y1, "-b", label="sine")
plt.plot(x, y2, "-r", label="cosine")
plt.legend(loc="upper left")
plt.ylim(-1.5, 2.0)
plt.show()