0
我正在嘗試創建一個完全自定義的圖例(即,我不想使用plt.legend
或plt.colorbar
。基於顏色映射,我希望能夠獲得顏色在顏色表的不同點。如何在matplotlib顏色映射中間隔確定顏色
gradient2n = LinearSegmentedColormap.from_list('gradient2n', ["white", "red"])
breaks = [0, 0.25, 0.5, 0.75, 1.0]
# something like this
print plt.colors_at_breaks(gradient2n, breaks)
["white", "light pink", "pink", "light red", "red"] #(or the hex/rgb equivalent)
任何理由要重新發明輪子? – tacaswell