← 返回章节索引

CHAPTER 03 · 作品已接入

标题与图例

用 title() 与 legend() 让多组数据易于辨识。

10075502500246810 Series ASeries B Title & Legend X axis Y axis
import matplotlib.pyplot as plt

plt.plot(x, y1, label='Series A')
plt.plot(x, y2, label='Series B')
plt.title('Title & Legend')
plt.legend(loc='upper right')
plt.show()
坐标轴标签标题与图例