I'd like to make this kind of scatter plot where the points have colors specified by the "c" option and the legend shows the color's meanings.
The data source of mine is like following:
scatter_x = [1,2,3,4,5]
scatter_y = [5,4,3,2,1]
group = [1,3,2,1,3] # each (x,y) belongs to the group 1, 2, or 3.
I tried this:
plt.scatter(scatter_x, scatter_y, c=group, label=group)
plt.legend()
Unfortunately, I did not get the legend as expected. How to show the legend properly? I expected there are five rows and each row shows the color and group correspondences.