How to visualize a list of strings on a colorbar in matplotlib
问题 I have a dataset like x = 3,4,6,77,3 y = 8,5,2,5,5 labels = "null","exit","power","smile","null" Then I use from matplotlib import pyplot as plt plt.scatter(x,y) colorbar = plt.colorbar(labels) plt.show() to make a scatter plot, but cannot make colorbar showing labels as its colors. How to get this? 回答1: I'm not sure, if it's a good idea to do that for scatter plots in general (you have the same description for different data points, maybe just use some legend here?), but I guess a specific