Starting with the following example:
fig, ax = plt.subplots()
df = pd.DataFrame({'n1':[1,2,1,3], 'n2':[1,3,2,1], 'l':['a','b','c','d']})
for label in df['l']:
df.plot('n1','n2', kind='scatter', ax=ax, s=50, linewidth=0.1, label=label)
I got the following scatter chart:

Now I'm trying to set a different color for each of the four dots. I know that I can iterate over a lot, for example, 4 colors in a list, for example:
colorlist = ['b','r','c','y']
but since my real dataset contains at least 20 different points, I was looking for a kind of “color generator” to focus on it.
source
share