How do you set a custom default colormap in MATLAB?

旧巷老猫 提交于 2019-12-23 09:41:32

问题


Someone asked this question elsewhere and was told there was a 'hint' here, but I'm quite new to MATLAB and don't see how to use that hint.

I have a file cmap.mat. I load it and update the colormap as follows:

load cmap.mat;
colormap(cmap);

But it only works for the current figure. I'd like all figures to use this colormap.


回答1:


To set a default property that all figures will use, you have to set that default value on the root object. Here's some better documentation explaining how to do it. In your case, you would do the following:

set(0,'DefaultFigureColormap',cmap);

In general, the property name you have to set will be the word 'Default' followed by the handle object name (i.e. 'Figure', 'Line', 'Surface', etc.) followed by the property name you are setting the default for. Once set, subsequent handle objects will be created with that property set to your specified default.

Note: The default property values you set will only last for the current MATLAB session. If you restart MATLAB, the default values will revert to their factory settings. To use the same defaults every time you start MATLAB, apply them within your 'startup.m' file.



来源:https://stackoverflow.com/questions/6034903/how-do-you-set-a-custom-default-colormap-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!