Easily make custom colormaps with any input type.

Version 1.1.0 (5,63 ko) par John Kearns
Make Color Map - Easily define custom colormap. Accepts any type of input, and has options for light-dark maps and unique inbuilt colormaps.
26 téléchargements
Mise à jour 1 août 2023

Afficher la licence

mcm - Make Color Map
Easily make colormaps with an input array of color values, designed to be simple to use and is ideal for beginners.
mcm() accepts numeric/rgb and hexidecimal as arrays where the rows correspond to individual colors in the map. mcm() also accepts MATLAB abbreviations as a single char or string, as in the example below.
All inputs must be of the same type (cannot use mix of numeric and hex, for example).
Length of the colormap and interpolation type may be specified, but these are optional inputs.
% Accepts any color input type.
% A red-white-blue colormap can be defined with
mapLength = 100; % Optional, Default = 256;
interType = 'nearest'; % Optional, Default = 'linear';
colors = 'rwb'; % These three inputs are all
colors = [1 0 0;1 1 1;0 0 1]; % accepted and produce identical
colors = ['#ff0101';'#ffffff';'#0101ff']; % colormaps in 'yourMap'.
yourMap = mcm(colors,mapLength,interpType);
colormap(gca,yourMap);
If a single color is input, yourMap will be a colormap that is centred about the input color that transitions from dark to light.
colors = 'm';
yourMap = mcm(colors);
If no input is given, mcm will generate a red-white-blue colormap that uses the MATLAB default red and blue from 'colororder'.
co = colororder;
colors = [co(1,:);% co(1,:) => MATLAB's default blue for plotting, first color used in plot(x,y)
[1 1 1]; % white, equivalent to 'w'.
co(5,:)];% co(5,:) => MATLAB's default red for plotting, fifth color used in plot(x,y)
yourMap1 = mcm(colors);
yourMap2 = mcm;
% isequal(yourMap1,yourMap2) = 1;
The latest version includes several predefined colormaps. They are detailed in the demo and in the comments of mcm(). Colormaps are
mapName = 'traffic';
mapName = 'cividis';
mapName = 'disco';
mapName = 'heatCam';
mapName = 'disco';
Colormap names are not case sensitive, and partial names (at least four characters) are sufficient to identify a particular colormap.

Citation pour cette source

John Kearns (2024). Easily make custom colormaps with any input type. (https://www.mathworks.com/matlabcentral/fileexchange/132767-easily-make-custom-colormaps-with-any-input-type), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2023a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Remerciements

Inspiré par : red-white-blue color map

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
1.1.0

Latest version includes more inbuilt colormaps.

1.0.0