colormap — Set or query a plotting colormap.
colormap sets or queries the color palette for the current or explicitly targeted plotting context. Public custom maps accept m-by-3 single or double RGB values in [0,1], or uint8 RGB values in [0,255]. Query output is a normalized host double matrix.
Syntax
cmap = colormap()
cmap = colormap(target)
colormap(name)
colormap(map)
colormap(target, map)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
target | Any | Yes | — | Target figure or axes handle. |
name | StringScalar | Yes | — | Colormap name. |
map | NumericArray | Yes | — | m-by-3 single/double RGB map in [0,1], or uint8 RGB map in [0,255]. |
map | Any | Yes | — | Colormap name or m-by-3 numeric RGB map. |
Returns
| Name | Type | Description |
|---|---|---|
cmap | NumericArray | Current colormap as an m-by-3 normalized double RGB matrix. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:colormap:InvalidArgument | Colormap input is missing, unknown, or not a valid m-by-3 RGB array. | colormap: invalid argument |
How colormap works
- Supported colormap names include
parula,colorcube,viridis,plasma,inferno,magma,turbo,jet,hot,cool,spring,summer,autumn,winter,gray,bone,copper,pink, andlines. - Named colormaps are also available as RGB array generator functions, so MATLAB forms such as
colormap(jet),colormap(gray(64)), andc = turbo(128)are supported. cmap = colormap()andcmap = colormap(target)return an m-by-3 normalized host double matrix. Setter forms do not expose an output.- Public RGB maps are m-by-3 single or double arrays in [0,1], or uint8 arrays in [0,255]. uint8 channels are normalized by division by 255 at the host graphics-state boundary.
- The other seven integer classes are a RunMat extension. They are accepted only when every native integer channel is exactly 0 or 1, and strict compatibility mode rejects the form before conversion.
- Resident RGB maps are rejected without provider access; colormap metadata and query results are host-resident.
- Unknown colormap names raise errors rather than silently falling back.
- Colormap state composes naturally with
colorbar,imagesc,surf, and filled contour plots. - Untargeted changes apply to the current axes. Targeted axes and figure forms update only the selected plotting context.
Examples
Apply a palette to a scaled image
[X, Y] = meshgrid(linspace(-3, 3, 60), linspace(-3, 3, 60));
A = sin(X) .* cos(Y);
imagesc(A);
colormap('jet');
colorbar;Compare palettes across subplots
[X, Y] = meshgrid(linspace(-3, 3, 40), linspace(-3, 3, 40));
Z = sin(X) .* cos(Y);
subplot(1, 2, 1);
surf(X, Y, Z);
colormap('parula');
subplot(1, 2, 2);
contourf(X, Y, Z);
colormap('turbo');Apply a generated RGB colormap matrix
surf(peaks(40));
colormap(parula(128));
colorbar;Apply a MATLAB-style named colormap generator
mandelbrot();
colormap(jet);Using colormap with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how colormap changes the result.
Run a small colormap example, explain the result, then change one input and compare the output.
FAQ
What colormaps are available?⌄
RunMat ships with: parula, colorcube, viridis, plasma, inferno, magma, turbo, jet, hot, cool, spring, summer, autumn, winter, gray, bone, copper, pink, and lines. Unknown names raise an error — no silent fallback.
Which colormaps are perceptually uniform?⌄
viridis, plasma, inferno, and magma are designed so that equal steps in data value produce equal perceptual changes in color. Use these for quantitative data where you want the visual contrast to faithfully represent magnitude differences. parula is also a good default. Avoid jet for quantitative work — it introduces false banding.
Can I define a custom colormap?⌄
Yes. Pass an m-by-3 single or double matrix in [0,1], or a uint8 matrix in [0,255]. RunMat mode also admits other integer classes when every channel is exactly 0 or 1.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · axes · barh · caxis · cla · clf · clim · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · linkaxes · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · stackedplot · subtitle · suptitle · text · textscatter · textscatter3 · triplot · waitbar · wordcloud · xlabel · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom
More plotting resources
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how colormap is executed, line by line, in Rust.
- View the source for colormap in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.