Can anyone help how to change the color of a set of points in a pyplot when i click on its legend labels?
Below is a code where there are two set of points x1 and x2. I am plotting them as a scatter plot. It plots all the points in set x1 and x2 in blue color. Is there any way to change the color of the points in set x1 to red when I click on the legend x1 label
import matplotlib.pyplot as plot
x1 = [1,3,5,7,9]
x2 = [2,4,6,8,10]
fig, ax = plot.subplots()
ax.scatter(x1,x1,color = 'b',s = 50,label = 'x1')
ax.scatter(x2,x2,color = 'b',s = 50,label = 'x2')
ax.legend(loc = 'upper left')
plot.show()