首页 > 行业资讯 > 默认配色辣眼睛?!那是你没发现这些宝藏学术颜色包(Colormaps)~~

默认配色辣眼睛?!那是你没发现这些宝藏学术颜色包(Colormaps)~~

时间:2021-12-11 来源: 浏览:

默认配色辣眼睛?!那是你没发现这些宝藏学术颜色包(Colormaps)~~

小詹学Python
小詹学Python

xiaozhan_Python

一个有温度的 Python 订阅号!

收录于话题

以下文章来源于DataCharm ,作者宁俊骐

DataCharm .

数据魅力,有技巧(数据可视化、数据分析、机器学习等)分享,有成长心得(学习、职场等),更有数据案例小报告,助你全方位发掘数据背后的价值。

这两天有小伙伴私信我说想使用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" )

Example01 Of scicomap
  • 样例二: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" )

Comparing scicomap color maps
  • 样例三:

f = sc.compare_cmap(image= "grmhd" ,                      ctype= ’sequential’ ,                      ncols=15,                      uniformize=True,                      symmetrize=True,                      unif_kwargs={ ’lift’ : 20},                      sym_kwargs={ ’bitonic’ : False,  ’diffuse’ : True})

Sequential color maps
  • 样例四:

f = sc.compare_cmap(image= "vortex" ,                      ctype= ’diverging’ ,                      ncols=15,                      uniformize=True,                      symmetrize=True,                      unif_kwargs={ ’lift’ : None},                      sym_kwargs={ ’bitonic’ : False,  ’diffuse’ : True})

Diverging color maps

更多关于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" )

Linear (sequential) colormaps, for plotting magnitudes
  • 样例二:

swatches(group= ’diverging’ )

Diverging colormaps, for plotting magnitudes increasing or decreasing from a central point
  • 样例三:

swatches(group= ’nopic’ )

Colorblind-safe colormaps
  • 样例四:

misc = [name  for  name  in  cc.all_original_names()  if   "cyclic"   in  name or  "isoluminant"   in  name or  "rainbow"   in  name] swatches(*misc)

Misc colormaps

更多关于colorcet颜色包详细内容,大家可参考: Python-colorcet包 [2]

Python-cmasher包

Python-cmasher包也是为学术配色所设计出的一个Matplotlib颜色包,这里直接列举几个色系即可,如下:

  • 样例一:Sequential colormaps
amber

amber_viscm
eclipse
eclipse_viscm
  • 样例二:Diverging colormaps
copper

copper_viscm
prinsenvlag

prinsenvlag_viscm

更多关于cmasher颜色包详细内容,大家可参考: Python-cmasher包 [3]

Python-viscm包

Python-viscm包是小编比较喜欢的一个,因为其提供了 MATLAB 的默认颜色主题,相信许多小伙伴还是蛮期待的,话不多说,直接列举样例,如下:

  • 样例一:PARULA
parula
  • 样例二:PLASMA
PLASMA
  • 样例三:VIRIDIS
VIRIDIS

更多关于viscm颜色包详细内容,大家可参考: Python-viscm包 [4]

偏艺术类型

这一部分我们给出的是一个偏 清新 的颜色,也就是 Python-vapeplot包 ,详细内容如下:

  • 样例一:

import vapeplot %matplotlib inline vapeplot.available()

vapeplot example
  • 样例二:

vapeplot.view_palette( "cool" , ’sunset’ )

view_palette
  • 样例三:cool
  • 样例四:avanti

更多关于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。

各位伙伴们好,詹帅本帅搭建了一个个人博客和小程序,汇集各种干货和资源,也方便大家阅读,感兴趣的小伙伴请移步小程序体验一下哦!(欢迎提建议)

推荐阅读

牛逼!Python常用数据类型的基本操作(长文系列第①篇)

牛逼!Python的判断、循环和各种表达式(长文系列第②篇)

牛逼!Python函数和文件操作(长文系列第③篇)

牛逼!Python错误、异常和模块(长文系列第④篇)

版权:如无特殊注明,文章转载自网络,侵权请联系cnmhg168#163.com删除!文件均为网友上传,仅供研究和学习使用,务必24小时内删除。
相关推荐