次の可能な値を持つ 150 個の変数のリストがあります。
domain = ['val1', 'val2', 'val2']
これらを変換して、matplot 散布図の色として使用したいと考えています。現在、データドメインから色の範囲に手動でマッピングする関数を作成しました。次のようなものです。
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)
これは機能しますが、ドメインの各要素がマップされる個々の色を指定する必要があります。cmaps を利用できるように、これに matplotlib を使用する方法はありますか? D3 には、データ ドメインから色範囲にマッピングする方法があります。