データに label を関連付け、plt.legend() で凡例を表示する。
例
from matplotlib import pyplot as plt
data_x = [25,26,27]
data_y = [39,41,50]
data_y2 = [40,20,17]
plt.plot(data_x,data_y,label='label 1')
plt.plot(data_x,data_y2,label='label 2')
plt.legend()
plt.show()
結果
![](https://hanjouchan.org/wp-content/uploads/2021/06/screenshot-2021-06-01-at-19.44.31-1024x893.png)