最近在学习Python的数据可视化,用到的是matplotlib。在学到color map这一块时,遇到了几个小问题。
1.matplotlib.cm.cool 在matplotlib的官网的cm下并未找到这个cool。后来在githup上找到了,以下就是相关链接。
(https://gist.github.com/endolith/2719900#id7)
那有了这些colormap,我们就可以很轻松的调用这些colormap了。
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
aa = plt.imshow(np.random.randint(1,10,(5,5)),plt.get_cmap('autumn'))
# aa = plt.imshow(np.random.randint(1,10,(5,5)),cmap=cm.autumn) 这2中写法作用一样
#添加一个colorbar
plt.colorbar(aa)
像所有的colormap均可以分为以下这几类,上图中的“autumn”就是属于Sequential这个category。