VIVID Creates a Personalized Colormap
VIVID(...) Creates a colormap with custom settings
M - (optional) an integer between 1 and 256 specifying the number of colors in the colormap. Default is 128.
MINMAX - (optional) is a 1x2 vector with values between 0 and 1 representing the intensity range for the colors, which correspond to black and white, respectively. Default is [0.15 0.85].
CLRS - (optional) either a Nx3 matrix of values between 0 and 1 representing the desired colors in the colormap
a string of characters that includes any combination of the following letters:
'r' = red, 'g' = green, 'b' = blue
'y' = yellow, 'c' = cyan, 'm' = magenta
'o' = orange, 'l' = lime green, 'a' = aquamarine
's' = sky blue, 'v' = violet, 'p' = pink
'k' or 'w' = black/white/grayscale
CMAP - an Mx3 colormap matrix
% Default Colormap
% Mapping With 256 Colors
% Mapping With Full Intensity Range
colormap(vivid([0 1])); colorbar
% Mapping With Light Colors
colormap(vivid([.5 1])); colorbar
% Mapping With Dark Colors
colormap(vivid([0 .5])); colorbar
% Mapping With Custom Color Matrix
clrs = [.5 0 1; 0 .5 1; 0 1 .5; .5 1 0; 1 .5 0; 1 0 .5];
% Mapping With Color String
% Colormap With Multiple Custom Settings
colormap(vivid(64,[.1 .9],'bwr')); colorbar
% Topo Colormap
imagesc(topo); axis xy; caxis([-6000 6000])
I feel great at being out programmed on this one. I can now spend more time understanding my results. Great job. (I do intend to read the code at some point)
Well done. Very useful and well designed/documented.
@Jiro, as per your suggestion, I made a modification to the file. Now the inputs are interpretted in order from low-to-high in accordance with the standard colormap convention.
Hi Joseph, I understand your logic. I guess it's just a difference in what we consider more intuitive. I think in terms of ascending order, so lowest (in value) to highest. Also I wanted it to keep the same logic for the usual colormaps in MATLAB. If I already had a colormap, and I wanted to "vivid-ify" it, I may want to do:
cm = colormap;
But this would flip it.
By the way, I have highlighted this entry on this week's Pick of the Week:
Thanks for the entry!
@Jiro, thank you. In regards to your example, it is not a bug if it was intentional. :o) I thought it was more intuitive to input colors top-to-bottom so that if inputs are provided in a "rainbow order", users would not have to think about the color sequence in reverse. For example:
would have red on top and green on the bottom, which I thought made more sense than:
However, if you do not like this feature, you can replace line 136 with the following:
>> rgb = repmat(reshape(clrs,1,nc,3),ns,1);
...where I just removed the call to flipud.
This is great Joseph! It's a very ingenious idea. I noticed a small bug. When you pass in a colormap (CLRS), it swaps the order. You can see the issue from this example:
Notice the "jet" colormap is swapped when I call with vivid - it goes from red to blue instead of blue to red.
This is one of the nice colormaps I've seen so far. Thanks.
it is great work!!! And thanks for sharing with us.
Whoops- forgot to rate in my previous review.
Nicely done. Works well and I already received compliments from a colleague on the colormap generated with this code that I used for a figure.
As per Jiro's suggestion, I reversed the order of the input colors to mimic the low-to-high that is typical for most colormaps.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.