Suppose I have three data sets:
X = [1,2,3,4]
Y1 = [4,8,12,16]
Y2 = [1,4,9,16]
I can scatter plot this:
from matplotlib import pyplot as plt
plt.scatter(X,Y1,color='red')
plt.scatter(X,Y2,color='blue')
plt.show()
How can I do this with 10 sets?
I searched for this and could find any reference to what I’m asking.
Edit: clarifying (hopefully) my question
If I call scatter multiple times, I can only set the same color on each scatter. Also, I know I can set a color array manually but I’m sure there is a better way to do this.
My question is then, “How can I automatically scatter-plot my several data sets, each with a different color.
If that helps, I can easily assign a unique number to each data set.
I don’t know what you mean by ‘manually’. You can choose a colourmap and make a colour array easily enough:
Or you can make your own colour cycler using
itertools.cycleand specifying the colours you want to loop over, usingnextto get the one you want. For example, with 3 colours:Come to think of it, maybe it’s cleaner not to use
zipwith the first one neither: