简化matplotlib颜色映射和颜色编解码器操作的实用程序(例如hex2rgb)
colormap的Python项目详细描述
有关最新文档,请参见:http://colormap.readthedocs.io/。
version: | Python 2.7, 3.3, 3.4, 3.5, 3.6 |
---|---|
contributions: | Please join https://github.com/cokelaer/colormap |
issues: | Please use https://github.com/cokelaer/colormap/issues |
notebook: | Please see https://github.com/cokelaer/colormap/tree/master/notebooks |
这是什么?
colormap包提供了在 rgb、hex、hls、huv和一个类,可以轻松地为matplotlib构建颜色映射。全部 matplotlib colormaps和一些r colormaps一起提供。这个 plot_colormap方法(见下文)可以方便地快速获取一个colormaps和 test_colormap对于查看test a new colormap很有用。
安装
pip install colormap
示例
创建自己的颜色映射,从红色到绿色,中间色为 白色(地图从红色变为绿色):
c = Colormap() mycmap = c.cmap( {'red':[1,1,0], 'green':[0,1,.39], 'blue':[0,1,0]}) cmap = c.test_colormap(mycmap)
如果颜色映射是线性的,则更简单:
c = Colormap() mycmap = c.cmap_linear('red', 'white', 'green(w3c)') cmap = c.test_colormap(mycmap)
查看可用的彩色地图:
c = Colormap() c.plot_colormap('diverging')
有关详细信息,请参阅联机文档:http://colormap.readthedocs.io/