Python:matplotlib.cm 色表
2021/11/25 11:10:26
本文主要是介绍Python:matplotlib.cm 色表,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
官网:Choosing Colormaps in Matplotlib — Matplotlib 3.5.0 documentation
Colormap与matplotlib.cm
我们以等高区域函数contourf为例,介绍matplotlib.cm的用法。关于contourf各参数的具体用法,这里不多说,有需要可以参考Python:matplotlib.pyplot - ShineLe - 博客园
plt.contourf( X , Y , Z,...,cmap=? )
在用contourf绘制等值区域时,cmap参数指定了色表样式,它有两种写法——str或Colormap实例,举例来说:
plt.contourf( X , Y , Z,...,cmap='hot' ) #等价于 plt.contourf( X , Y , Z,...,cmap=matplotlib.cm.hot)
以上都是用同一个colormap进行等值区域绘制的,结果如下:
这就是colormap的用法。而matplotlib.cm中提供许多colormap,足够我们日常工作学习需要。
matplotlib.cm中的色表
官网:Colormap reference — Matplotlib 3.5.0 documentation
使用时,在需要填入colormap的地方,可以通过两种写法使用colormap,①字符串形式的色表名:'hot';②matplotlib.cm.色表名:matplotlib.cm.hot。
cm中的色表罗列如下:
这篇关于Python:matplotlib.cm 色表的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python