I have data that looks like X_1 = [...]
, X_2 = [...]
, Y = [...]
. The values in Y
are integers representing labels and the values in X_1
and X_2
are floats. I want to make a scatterplot of X_1
vs X_2
, and have points coloured in using Y
. I can do
plt.scatter(X_1, X_2, c=Y)
but I can't find any documentation describing how to get a legend that shows, for each label in Y
, the corresponding colour used for the marker.
How can I create this legend?