I have a list of 150 variables that have the following possible values:
domain = ['val1', 'val2', 'val2']
I want to convert these to be used as color for a matplot scatter plot. Currently I wrote a function to manually map from my data domain to a color range, something like:
colors = ['aquamarine','purple','blue']
color_map = dict(zip(domain, colors))
colorize = lambda x : color_map[x]
c = list(map(colorize, labels))
#and then I explicitly pass the array to scatter:
scatter = ax.scatter(t_x,
t_y,
c=c,
alpha=0.3,
cmap=plt.cm.cool,
s = 500)
This works, however, I must specify the color individual colors that each element of my domain gets mapped to. Is there a way to have matplotlib to this for me, so I can take advantage of cmaps? D3 has a way of mapping from a data domain to color range.