Built in colormaps in Matlab

2019-07-17 03:13发布

问题:

I want a lighter version of the "cyan" color, using the function colormap('cyan'). How do you do this?

回答1:

Check out the function BRIGHTEN:

X = spiral(8);
image(X)
colormap(winter), colorbar
brighten(0.6)

Another trick is to right click on the colorbar and select Interactive Colormap Shift, this allows to shift the color-to-data mapping using mouse dragging.



回答2:

Pure cyan is represented by the RGB triple [0 1 1]. To make it lighter, just increase the red component (ex: [0.5 1 1]), thus moving it closer to pure white ([1 1 1]). If you want to make a colormap that spans from pure cyan through lighter shades of cyan all the way to pure white, you can do the following:

nValues = 128;  %# The number of unique values in the colormap
map = [linspace(0,1,nValues)' ones(nValues,2)];  %'# 128-by-3 colormap

Now you can set the colormap to the one made above using the COLORMAP function:

colormap(map);

For more discussion of colors in MATLAB, check out this link.



回答3:

For me colormap('cyan') fails because cyan is undefined.

However, you can create your own colors easily. If cyan is equivalent to [0,1,1] a lighter color would be [0,1,1] + [.1,0,0] = [.1,1,1] or rather just increase the R in RGB to increase the luminosity.