Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set a custom default colormap in MATLAB?

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.

like image 436
mankoff Avatar asked May 17 '11 17:05

mankoff


People also ask

What is the default colormap in Matlab?

If you have not specified a different default value, then the default colormap is parula .

What is Colormap HSV in Matlab?

hsvmap — HSV colormap HSV colormap, returned as a c-by-3 numeric matrix with values in the range [0, 1]. Each row of hsvmap is a three-element HSV triplet that specifies the hue, saturation, and value components of a single color of the colormap.

How do I open colormap editor in Matlab?

Open the Colormap Editor MATLAB command prompt: Enter colormapeditor .


1 Answers

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.

like image 181
gnovice Avatar answered Sep 22 '22 15:09

gnovice