File Exchange

image thumbnail


version 1.5.3 (48.7 KB) by Laurens R Krol
An adjustable multiple-colour gradient colour map generator / editor for MATLAB

1 Download

Updated 18 Jan 2019

GitHub view license on GitHub

This script allows you to generate a colour scale (as for colormap, colorbar) using any number of custom colours, and allows you to arrange these colours by adjusting their relative positions with respect to each other, much like you may be used to creating gradients in e.g. Adobe Photoshop or CorelDRAW. It will automatically interpolate the colours in between the indicated anchor points.

In its most basic form, simply call the script using an n-by-3 matrix of RGB values, and it will generate the colour map accordingly. For example, multigradient([1 0 0; 1 1 0; 0 1 0]) will return a map that blends from red through yellow to green, of the same size as the current figure's color map. Further tricks are optional.

* Interpolation in RGB space. Simple linear interpolation of the given RGB values.
* Interpolation in HSV space. Linear interpolation of the values after conversion into HSV, for e.g. the rainbow colormap: multigradient([1 0 0; 0 0 1], 'interp', 'hsv').
* Isoluminant interpolation in L*a*b* space. The L* value is equalised for all given colours before linear interpolation and conversion back to RGB. Note that some colour clipping may occur due to the gamut differences.
* Interpolation in Kenneth Moreland's Msh space for divergent colour maps for scientific visualisation. A neutral unsatured middle point is automatically inserted if the two endpoint colours for the diverging map are sufficiently distinct. See: Moreland, K. (2009). Diverging color maps for scientific visualization. In Proceedings of the 5th International Symposium on Visual Computing, doi: 10.1007/978-3-642-10520-3_9 mirrored at
* Control points allow the relative distances between the colours to be adjusted.
* Many presets, including colour scales designed by Kenneth Moreland ( and Cynthia Brewer (, are included.
* Colour scales can easily be reversed.

Cite As

Laurens R Krol (2019). multigradient (, GitHub. Retrieved .

Comments and Ratings (2)

Dear Mr Cobeldick, in the current version (1.5.3), lines 92 to 95 contain the acknowledgement and license as suggested by the ColorBrewer documentation. multigradient itself is licensed under the GPLv3, which is compatible with the ColorBrewer's Apache 2.0 license. I will of course immediately update this should it be found to be insufficient.

Interesting submission, handy colormap editor.

Note that distributing Cynthia Brewer's colormaps requires an acknowledgement in the documentation and her license to be included, but I could not find either of these in the downloaded files. The full license and conditions are here (there is a link from <>):




- Updated preset naming convention
- Reversed colours to maintain cold -> warm consistency
- Code clean-up


- Added L*a*b* isoluminant interpolation (labiso)
- Added Msh divergent interpolation (mshdiv)
- Added preset argument with some initial presets
- Added reverse argument
- Enabled middle control point for two-colour maps

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor