meatball1982 发表于 2019-10-26 20:11:31

豆粑粑 matlab 调用python的colormap

本帖最后由 meatball1982 于 2023-2-14 23:39 编辑

最近几天,帮忙组里一个孩子画几个图,觉得python的colormap着实是漂亮。
matlab的colormap相比于python还是太过单调,虽然只要知道对应的RGB值,matlab也能生成对应的colormap,但每次去找,总是觉得麻烦。
有否可能通过python的colormap名字,直接生成matlab的colormap。然后用就行了。
总是有大神之人会帮忙你把这类事给作好的,只要你去找。
PyColormap4Matlab
就是专门作这事儿的。
剩下的,就是把所有的colormap用于作图,然后,你选择就行了。
我是所有的colormap的colorbar
上面是名字。
如果想得到与名字对就的相反的colormap_r,用matlab 的flipud直接转一下就好。


nam_mat_py = { ...    % ---Perceptually Uniform Sequential ---------------------            'viridis'; 'plasma'; 'inferno'; 'magma'; 'cividis';...    % -----Sequential----------------------------------------         'Greys'; 'Purples'; 'Blues'; 'Greens'; 'Oranges'; 'Reds';...         'YlOrBr'; 'YlOrRd'; 'OrRd'; 'PuRd'; 'RdPu'; 'BuPu';...         'GnBu'; 'PuBu'; 'YlGnBu'; 'PuBuGn'; 'BuGn'; 'YlGn';...    % -----Sequential 2-------------------------------------------         'binary'; 'gist_yarg'; 'gist_gray'; 'gray'; 'bone';...         'pink'; 'spring'; 'summer'; 'autumn'; 'winter'; 'cool';...         'Wistia'; 'hot'; 'afmhot'; 'gist_heat'; 'copper';...    % -----Diverging-------------------------------------------         'PiYG'; 'PRGn'; 'BrBG'; 'PuOr'; 'RdGy'; 'RdBu'; 'RdYlBu';...         'RdYlGn'; 'Spectral'; 'coolwarm'; 'bwr'; 'seismic';...    % -----Cyclic--------------------------------------------         'twilight'; 'twilight_shifted'; 'hsv';...    % -----Qualitative-----------------------------------------------         'Pastel1'; 'Pastel2'; 'Paired'; 'Accent'; 'Dark2';...         'Set1'; 'Set2'; 'Set3'; 'tab10'; 'tab20'; 'tab20b';'tab20c';...    % -----Miscellaneous------------------------------------------         'flag'; 'prism'; 'ocean'; 'gist_earth'; 'terrain';...         'gist_stern'; 'gnuplot'; 'gnuplot2'; 'CMRmap';...         'cubehelix'; 'brg'; 'gist_rainbow'; 'rainbow'; 'jet';...         'Spectral';'nipy_spectral'; 'gist_ncar'...    % ----------------------------------------------------------         };

通过crameri函数,实现多数文献中的colormap
个人感觉,更加暗一些。
这里,只能通过flipud来实现colormap的翻转。


nam_mat_sf = { ...    %------- Sequential --------------------------         'batlow';'batlowW';'batlowK';'devon';'lajolla';'bamako';'davos';...         'bilbao';'nuuk';'oslo';'grayC';'hawaii';'lapaz';'tokyo';'buda';...         'acton';'turku';'imola';...    %-------- Diverging --------------------------         'broc';'cork';'vik';'lisbon';'tofino';'berlin';'roma';'bam';...         'vanimo';'oleron';'bukavu';'fes';...    % ------- Cyclic -----------------------------         'romaO';'bamO';'brocO';'corkO';'vikO'};

file_imgs中是所有的colormap画peaks函数,透明度选择0.8的效果。
非透明可以通过侧面的colorbar观看。











meatball1982 发表于 2023-2-14 13:17:04

本帖最后由 meatball1982 于 2023-2-14 14:42 编辑

更新一下fun_mm_pycm函数。
有几个新的可用的colormap

页: [1]
查看完整版本: 豆粑粑 matlab 调用python的colormap