免费html网站代码,天津卓信软件开发有限公司,单页网站 挣钱,seo技术蜘蛛屯本篇详细介绍matplotlib内置的颜色条Colormap使用。
本文将学到什么#xff1f;
1、colormap名称
2、colormap可视化
3、colormap使用方法
4、参考资料
更好的阅读体验请戳#xff1a;
1、colormap名称
colormap颜色通过matplotlib的cm模块调用#xff0c;print(dir(cm))即可…本篇详细介绍matplotlib内置的颜色条Colormap使用。
本文将学到什么
1、colormap名称
2、colormap可视化
3、colormap使用方法
4、参考资料
更好的阅读体验请戳
1、colormap名称
colormap颜色通过matplotlib的cm模块调用print(dir(cm))即可输出所有的名称共计81种Colormap不包含反向色条例如
Reds的反向色条Reds_r详细如下
[Accent, Blues, BrBG, BuGn, BuPu, CMRmap, Dark2, GnBu, Greens, Greys, OrRd, Oranges, PRGn, Paired, Pastel1, Pastel2, PiYG, PuBu, PuBuGn, PuOr, PuRd, Purples, RdBu, RdGy, RdPu, RdYlBu, RdYlGn, Reds, Set1, Set2, Set3, Spectral, Wistia, YlGn, YlGnBu, YlOrBr, YlOrRd, afmhot, autumn, binary, bone, brg, bwr, cividis, cool, coolwarm, copper, cubehelix, flag, gist_earth, gist_gray, gist_heat, gist_ncar, gist_stern, gist_yarg, gnuplot, gnuplot2, gray, hot, hsv, inferno, jet, magma, nipy_spectral, ocean, pink, plasma, prism, rainbow, seismic, spring, summer, tab10, tab20, tab20b, tab20c, terrain, twilight, twilight_shifted, viridis, winter]
2、 colormap可视化
每个 colormap到底包含哪些颜色了上图image
3、colormap使用方法
colormap分ListedColormap下图中Accent和LinearSegmentedColormap下图中Blues两种前一种存储特定的颜色比如说红白黑三种使用colors可以取出所有的RGBA色号值后一种可能是渐变色无colors属性。下面详细介绍怎么使用 colormap。
import matplotlib.pyplot as plt
from matplotlib import cm
plt.figure(dpi150)
##ListedColormap
#取多种颜色
plt.subplot(1,4,1)
#plt.bar(range(5),range(1,6),colorplt.cm.Accent(range(5)))
#plt.bar(range(5),range(1,6),colorplt.cm.get_cmap(Accent)(range(5)))
plt.bar(range(5),range(1,6),colorplt.get_cmap(Accent)(range(5)))
#取某一种颜色
plt.subplot(1,4,2)
plt.bar(range(5),range(1,6),colorplt.cm.Accent(4))
##LinearSegmentedColormap
#取多种颜色
plt.subplot(1,4,3)
plt.bar(range(5),range(1,6),colorplt.get_cmap(Blues)(np.linspace(0, 1, 5)))
#取一种颜色
plt.subplot(1,4,4)
plt.bar(range(5),range(1,6),colorplt.get_cmap(Blues)(3))image
4、参考资料