有小伙伴私信我说想使用Python-Matplotlib绘制一些学术图表,都纷纷吐槽其默认的颜色表(colormap) 真的是一言难尽。哈哈,小编也是这么觉得的,那么,今天这篇推文,小编就系统介绍一下优秀的关于Matplotlib颜色表(colormap) 第三方库。主要内容如下:
偏学术类型
偏艺术类型
偏学术类型
Python-Matplotlib的偏学术类型的colormap,想必是很多小伙伴急需了解的,小编就介绍以下几个库,当然,还有小伙伴们心心念念的MATLAB的颜色表哦~
Python-scicomap包
Python-scicomap包可以说是专门为Matplotlib提供科学学术图表的配色,其含有单色系(sequential), 双单色系(bi-sequential), 双色渐变系(diverging), 循环色系(circular), 多色系(qualitative) 和混杂色系(miscellaneous) 颜色表。接下来我们列举下几个样例查看下:
样例一:
import scicomap as sc
import matplotlib.pyplot as plt
# the thing that should not be
ugly_jet = plt.get_cmap("jet")
sc_map = sc.ScicoMiscellaneous(cmap=ugly_jet)
f=sc_map.assess_cmap(figsize=(22,10))
f.set_facecolor("w")
样例二:Comparing color maps
c_l = ["cividis", "inferno", "magma", "plasma", "viridis"]
f = sc.plot_colorblind_vision(ctype='sequential',
cmap_list=c_l,
figsize=(30, 4),
n_colors=11,
facecolor="black")
![7265d037d9d8ea044705c4f8bc934c23.png](https://img-blog.csdnimg.cn/img_convert/7265d037d9d8ea044705c4f8bc934c23.png)
样例三:
f = sc.compare_cmap(image="grmhd",
ctype='sequential',
ncols=15,
uniformize=True,
symmetrize=True,
unif_kwargs={'lift': 20},
sym_kwargs={'bitonic': False, 'diffuse': True})
样例四:
f = sc.compare_cmap(image="vortex",
ctype='diverging',
ncols=15,
uniformize=True,
symmetrize=True,
unif_kwargs={'lift': None},
sym_kwargs={'bitonic': False, 'diffuse': True})
更多关于scicomap颜色包详细内容,大家可参考:Python-scicomap包[1]
Python-colorcet包
colorcet包包含太多类型的颜色系了,这里也不过多赘述,直接上案例:
样例一:
import holoviews as hv
import colorcet as cc
from colorcet.plotting import swatches, sine_combs
hv.notebook_extension("matplotlib")
swatches(group="linear")
![26ae1e7e923e1580242694548d809434.png](https://img-blog.csdnimg.cn/img_convert/26ae1e7e923e1580242694548d809434.png)
样例二:
swatches(group='diverging')
![00a91d3ee8dd56354a6033a289ef8750.png](https://img-blog.csdnimg.cn/img_convert/00a91d3ee8dd56354a6033a289ef8750.png)
样例三:
swatches(group='nopic')
![3eec93645ebbd5546eda53fe654a2e7e.png](https://img-blog.csdnimg.cn/img_convert/3eec93645ebbd5546eda53fe654a2e7e.png)
样例四:
misc = [name for name in cc.all_original_names() if "cyclic" in name or "isoluminant" in name or "rainbow" in name]
swatches(*misc)
![9f4e243d51e87ba97d2512ce22eb8cb6.png](https://img-blog.csdnimg.cn/img_convert/9f4e243d51e87ba97d2512ce22eb8cb6.png)
更多关于colorcet颜色包详细内容,大家可参考:Python-colorcet包[2]
Python-cmasher包
Python-cmasher包也是为学术配色所设计出的一个Matplotlib颜色包,这里直接列举几个色系即可,如下:
样例一:Sequential colormaps
![76f9db80548db19cdf4a929900bf5af2.png](https://img-blog.csdnimg.cn/img_convert/76f9db80548db19cdf4a929900bf5af2.png)
![c6ef29c9dd4556f91ab80b6851140337.png](https://img-blog.csdnimg.cn/img_convert/c6ef29c9dd4556f91ab80b6851140337.png)
![194ca300fa5ed3beff658df6772e5759.png](https://img-blog.csdnimg.cn/img_convert/194ca300fa5ed3beff658df6772e5759.png)
样例二:Diverging colormaps
![4e8b8eaec4e6f38b4b0c9e71ad4c1c90.png](https://img-blog.csdnimg.cn/img_convert/4e8b8eaec4e6f38b4b0c9e71ad4c1c90.png)
![f128998c27e0f20bfa67678e62c26375.png](https://img-blog.csdnimg.cn/img_convert/f128998c27e0f20bfa67678e62c26375.png)
更多关于cmasher颜色包详细内容,大家可参考:Python-cmasher包[3]
Python-viscm包
Python-viscm包是小编比较喜欢的一个,因为其提供了MATLAB的默认颜色主题,相信许多小伙伴还是蛮期待的,话不多说,直接列举样例,如下:
样例一:PARULA
![e460fcd6224ded9564a7c3c7133ce513.png](https://img-blog.csdnimg.cn/img_convert/e460fcd6224ded9564a7c3c7133ce513.png)
样例二:PLASMA
![b5373600eb668f6e9048d732f6ca4d4b.png](https://img-blog.csdnimg.cn/img_convert/b5373600eb668f6e9048d732f6ca4d4b.png)
样例三:VIRIDIS
![268b2a77b46a2d65d7c406f94228c8d5.png](https://img-blog.csdnimg.cn/img_convert/268b2a77b46a2d65d7c406f94228c8d5.png)
更多关于viscm颜色包详细内容,大家可参考:Python-viscm包[4]
偏艺术类型
这一部分我们给出的是一个偏清新的颜色,也就是Python-vapeplot包,详细内容如下:
样例一:
import vapeplot
%matplotlib inline
vapeplot.available()
![ee8c2fb0bfba0a930cc8a4ea9167f39b.png](https://img-blog.csdnimg.cn/img_convert/ee8c2fb0bfba0a930cc8a4ea9167f39b.png)
样例二:
vapeplot.view_palette("cool",'sunset')
![bc7a4a91fe18993563baa76d1d31ea4a.png](https://img-blog.csdnimg.cn/img_convert/bc7a4a91fe18993563baa76d1d31ea4a.png)
样例三:cool
![d8973234429ba9a1678db441fcb9d6c4.png](https://img-blog.csdnimg.cn/img_convert/d8973234429ba9a1678db441fcb9d6c4.png)
![e0773ff07c75f71e957378928045d50a.png](https://img-blog.csdnimg.cn/img_convert/e0773ff07c75f71e957378928045d50a.png)
样例四:avanti
![121cddc6f509f1df8e4eede61a7ec06b.png](https://img-blog.csdnimg.cn/img_convert/121cddc6f509f1df8e4eede61a7ec06b.png)
![1a460388bc9fa77c0f1bf52730e2bf46.png](https://img-blog.csdnimg.cn/img_convert/1a460388bc9fa77c0f1bf52730e2bf46.png)
更多关于vapeplot颜色包详细内容,大家可参考:Python-vapeplot包[5]
总结
本期这篇推文小编给大家列举了几个学术和商业Matplotlib颜色包,大家可以选择自己喜欢的学术配色进行论文的绘制~~
参考资料
[1]
Python-scicomap包: https://github.com/ThomasBury/scicomap。
[2]Python-colorcet包: https://colorcet.holoviz.org/。
[3]Python-cmasher包: https://cmasher.readthedocs.io/。
[4]Python-viscm包: https://bids.github.io/colormap/。
[5]Python-vapeplot包: https://github.com/dantaki/vapeplot。
-------- End --------
推荐👇同名微信视频号
![4f0b456a7a7e749721d27cbb997bf54f.jpeg](https://img-blog.csdnimg.cn/img_convert/4f0b456a7a7e749721d27cbb997bf54f.jpeg)
图解Pandas
图文00-内容框架介绍 | 图文01-数据结构介绍 | 图文02-创建数据对象 | 图文03-操作Excel文件 | 图文04-常见的数据访问 | 图文05-常见的数据运算 | 图文06-常见的数学计算 | 图文07-常见的数据统计 | 图文08-常见的数据筛选 | 图文09-常见的缺失值处理 | 图文10-数据合并操作 | 图文11-Groupby分组操作
![f0b8af4870c380de2b4388206a41a535.jpeg](https://img-blog.csdnimg.cn/img_convert/f0b8af4870c380de2b4388206a41a535.jpeg)
![81696620de03f94126ef684e4fe90aef.jpeg](https://img-blog.csdnimg.cn/img_convert/81696620de03f94126ef684e4fe90aef.jpeg)