关于颜色的散点图图例 [Python3]

Scatter plot legend with respect to colour [Python3]

我有六个点的 MWE 可以绘制:

import matplotlib.pyplot as plt

plt.scatter(1,2,marker= 'o', color='darkred')
plt.scatter(3,5,marker= 'o', color='yellowgreen')
plt.scatter(11,21,marker= 'o', color='black')
plt.scatter(4,6,marker= 'o', color='blue')
plt.scatter(8,11,marker= 'o', color='yellowgreen')
plt.scatter(2,3,marker= 'o', color='darkred')
plt.show()

我想写一个基于颜色的图例 例如

蓝色 --> first_experiment

黄绿色 --> second_experiment

等等。

有什么想法吗?

尝试添加 label 选项:

plt.scatter(1,2,marker= 'o', color='darkred',label='first')
plt.scatter(3,5,marker= 'o', color='yellowgreen', label='second')
plt.scatter(11,21,marker= 'o', color='black')
plt.scatter(4,6,marker= 'o', color='blue')
plt.scatter(8,11,marker= 'o', color='yellowgreen')
plt.scatter(2,3,marker= 'o', color='darkred')

# add the legend
plt.legend()

# show the plot
plt.show()

输出: