Written and maintained by CASRAI Editorial Board
Last updated
A MATLAB colormap is an m-by-3 matrix of red, green, blue values that tells MATLAB which color to draw for each data value in a surface, image, contour or scatter plot. This guide is for researchers and analysts who need to pick a built-in map, build their own, and add a colorbar so the figure can be read. The default map is parula; you change it with the colormap function.
What colormaps are used for in research figures
Any plot that encodes a third variable as color (heat maps, surface plots, spectrograms, image data) depends on its colormap to be readable. MathWorks documents parula, the default, as having transitions between colors that are “more perceptually uniform than in most other colormaps,” and documents turbo as a scheme similar to jet with transitions more perceptually uniform than in jet. Perceptual uniformity matters because equal steps in the data should look like equal steps in color; the Matplotlib documentation states the same principle: a perceptually uniform colormap is “a colormap in which equal steps in data are perceived as equal steps in the color space.” For journal figure requirements beyond color, see scientific figure rules for journal submission and designing effective scientific figures.
Access: where the colormap functions come from
The colormap, colorbar, parula and turbo functions are documented in the core MATLAB reference on the MathWorks documentation site (colormap, turbo, colorbar; checked 2026-11-07). Obtain MATLAB only from MathWorks. Several maps were added in specific releases (see the table below), so a map missing from an older installation may simply be newer than that release.
Built-in MATLAB colormaps
The colormap reference page lists these predefined colormaps. Release notes are included only where the MathWorks pages state them.
| Colormap | What the documentation says |
|---|---|
parula |
Default colormap unless you specify otherwise; transitions more perceptually uniform than in most other colormaps |
turbo |
Introduced in R2020b; similar color scheme to jet with more perceptually uniform transitions than jet |
jet |
Predefined colormap; the turbo page compares itself against it |
sky |
Added in R2023a |
abyss |
Added in R2023b |
nebula |
Added in R2025a |
hsv, hot, cool, spring, summer, autumn, winter, gray, bone, copper, pink, lines, colorcube, prism, flag, white |
Predefined colormaps listed on the reference page |
Step by step: set a colormap and add a colorbar
- Create a plot. For example,
surf(peaks)draws a surface colored by height. - Apply a predefined colormap. Call
colormap(turbo). The command formcolormap turbois also documented (colormap map). - Set the number of colors. Predefined maps take a length, for example
colormap(parula(5))for five colors. - Target a specific axes or figure. Use
colormap(target,map). - Read the current map.
cmap = colormapreturns the current colormap as a matrix;cmap = colormap(target)returns it for a given target. - Add a colorbar. Call
colorbarto add a vertical colorbar to the right of the current axes. Usecolorbar('northoutside')to choose a location,c = colorbarto get the ColorBar object for further changes, andcolorbar('off')to remove it. - Reverse the colorbar direction if needed.
colorbar(Direction="reverse")uses the documented name-value syntax. - Restore the default.
colormap defaultreturns to the system default colormap.
Custom colormaps (custom RGB)
The documentation says a colormap “can be any length, but must be three columns wide.” Each row is one color, with red, green and blue intensities as doubles or singles from 0 to 1 (uint8 values from 0 to 255 are also accepted). The documented example builds a six-color blue ramp and applies it:
map = [0 0 0.3; 0 0 0.4; 0 0 0.5; 0 0 0.6; 0 0 0.8; 0 0 1.0];
surf(peaks)
colormap(map)
colorbar
The same matrix shape works for any number of rows, so a custom map can also be generated by code and passed straight to colormap.
Output and how to read it
After colormap runs, the plot recolors immediately; the colorbar shows which color maps to which data value. A colorbar is part of the evidence in the figure, so label it with the quantity and units. A matching Python walkthrough is in colorbar in Matplotlib, and heatmap in Matplotlib shows the same idea for gridded data.
Troubleshooting
Why does my custom colormap fail?
Check the matrix shape first: it must be three columns wide (red, green, blue), with values from 0 to 1 for double or single data.
Why did my colors revert to the default?
If no other default is set, the default colormap is parula. colormap default restores it.
Why is a map name not recognized?
The newer maps (sky, abyss, nebula) were added in R2023a, R2023b and R2025a respectively, and turbo in R2020b. Older releases will not have them.
How do I get a colorbar off the figure?
colorbar('off') removes it.
Viridis, magma, inferno and coolwarm in MATLAB
These four names do not appear in the predefined list on the MATLAB colormap reference page (checked 2026-11-07). The maps themselves are documented elsewhere: Matplotlib lists viridis, plasma, inferno, magma and cividis as perceptually uniform sequential colormaps and coolwarm among its diverging maps, noting that coolwarm “has little range of gray scale and would print to a more uniform plot, losing a lot of detail.” In MATLAB, the documented way to use any map you have as RGB values is the custom three-column matrix route above, or a third-party File Exchange package, which MathWorks does not document on the reference page.
Free alternatives
| Tool | Colormap support (from its documentation) |
|---|---|
| GNU Octave | colormap function; map = viridis () or viridis (n) creates a map running from dark purplish-blue through blue and green to yellow; colormap ("default") restores the default, a 64-entry viridis map |
| Python Matplotlib | Perceptually uniform sequential maps viridis, plasma, inferno, magma, cividis; diverging maps include coolwarm |
FAQ
What is the default colormap in MATLAB?
Parula, unless you specify a different default. colormap default restores it.
Is viridis built into MATLAB?
It is not in the predefined list on the colormap reference page. Use a custom RGB matrix or a File Exchange package.
How do I make a custom colormap?
Create a matrix with three columns (red, green, blue), values from 0 to 1, any number of rows, then call colormap(map).
What is a perceptually uniform colormap?
One in which equal steps in the data are perceived as equal steps in color (Matplotlib documentation). MathWorks describes parula and turbo as more perceptually uniform than most other maps and than jet, respectively.







