【源码】PyColormap4Matlab:将颜色映射从matplotlib导入Matlab的Matlab和python脚本

640?wx_fmt=jpeg

getPyPlot_cMap返回matplotlib python库中实现的任何颜色映射。

getPyPlot_cMap returns any colormap implemented in the matplotlib python library. 


它调用python脚本,该脚本将颜色映射矩阵写入一个临时文件,即需要安装python(包括matplotlib模块)。

It calls a python script that writes the colormap matrix into a temporary file, i.e. PYTHON (and the matplotlib module) is REQUIRED. 


然而,它的优点是可以在matplotlib中实现所有的颜色映射,并且可以指定RGB量化级别的数量,即映射颜色数量

However, the advantage is that you get all the colormaps implemented in matplotlib and that you can specify the number of RGB quantization levels, i.e. the number of colors of the colormap.


函数帮助部分提供了一个颜色映射名称列表。

A list of colormap names is provided in the function help section. 


getPyPlot_cMap('!GetNames') returns a cellstring containing all available colormap names. See https://matplotlib.org/examples/color/colormaps_reference.html for an illustration of colormaps.


================================================= 

具体使用方法:

Usage


cMapNames = getPyPlot_cMap('!GetNames') 

Returns a cellstring containing all available colormap names.


cMap = getPyPlot_cMap(cMapName) 

Returns the colormap cMapName with the default of 128 colors. cMap will be a 128x3 matrix.


cMap = getPyPlot_cMap(cMapName, NumberOfColors) 

Specify the number of colors, i.e. the number of rows in cMap.


cMap = getPyPlot_cMap(cMapName, NumberOfColors, keepAlphaChannel) 

If keepAlphaChannel is not 0 cMap has a 4th column containing the alpha channel.


cMap = getPyPlot_cMap(cMapName, NumberOfColors, keepAlphaChannel, pythonSystemCommand) 

Lets you specify the python command (possibly including a path, see below) used to execute the python script.


=================================================

常见错误的解决方法: 

Errors


If you have python installed but Matlab says 'There was an error executing the command... System returned:...' you can try to pass the path to your python installation explicitly as the 4th parameter, e.g.:


cmp = getPyPlot_cMap('Accent', [], [], '"c:\Program Files\Python37\python.exe"');


Note the double-quotes around the path, which are neccessary because of the containing space character.


完整资料领取请加QQ群免费下载:

640?wx_fmt=png

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值