1 cmap
matplotlib有自己定义的cmap,包括Sequential,Diverging,Cyclic,Qualitative几种定义好的,当然也可以自定义,更详细的可以查看官网Choosing Colormaps in Matplotlib
2 palette
seaborn是另一个可视化的库,他也有一个很好用的palette调色板,种类比matplotlib更多,而且自定义更方便,更多可以查看官网:Choosing color palettes
3 将palette应用为cmap
那么我们如何将seaborn里的palette应用为cmap呢?
两行代码足矣:
from matplotlib.colors import ListedColormap
cmap = ListedColormap(sns.color_palette())
详见seaborn color_palette as matplotlib colormap