Home > database >  matlplotlib scatterplot with numbers as symbols legend
matlplotlib scatterplot with numbers as symbols legend

Time:09-22

I would like to draw a scatterplot that has colored numbers instead of points as symbols. I did as follow

n=np.arange(1,14,1)

fig, axs = plt.subplots(1, 2)

axs[0].scatter(x, y, linestyle='None', color="white")

for i, txt in enumerate(n):
     axs[0].annotate(txt, (x[i], y[i]), color=x_y_colours[i], ha="center", va="center")
       

It worked but now I don't know how to create the legend! I would like to have colored numbers as the symbol and then the label.

Thank you all!

CodePudding user response:

You can use text or digits as scatter markers

  • Related