colormap
set and/or get a figure/axes colormap.
Syntax
cmap = colormap() cmap = colormap(h) cmap = colormap(m) cmap = colormap(h, m) colormap(m) colormap(h, m)
Arguments
- h
A figure or axes handle. If not given the current figure is used (See gcf).
- m
A string (function name), a function, a Nx3 double matrix or
"default"(to reset colormap to the default one). The color map to be used.
Description
colormap function is a helper to manage colormaps.
cmap = colormap() returns the current figure colormap.
cmap = colormap(h) returns the colormap of the figure/axes handle h.
[cmap =] colormap(m) sets the colormap m to the current figure. cmap is only returned when the output of the function is assigned.
[cmap =] colormap(h, m) sets the colormap m to the figure/axes handle h. cmap is only returned when the output of the function is assigned.
Examples
x = %pi * [-1:0.05:1]'; z = sin(x)*cos(x)'; f=scf(); // Change colormap to parula (32 values) colormap(parula(32)); ax1 = subplot(1, 2, 1); ax1.title.text = "plot3d() using figure colormap"; e = plot3d(x, x, z, 70, 70); e.color_flag = 1; ax2 = subplot(1, 2, 2); ax2.title.text = "plot3d() using axes colormap" // Change colormap to jet (default size) colormap(ax2, jet); // Equivalent to colormap(ax2, "jet") e = plot3d(x, x, z, 70, 70); e.color_flag = 1;
See also
- Using colormaps — Using colormaps in graphics.
- jet
- parula
- gcf — Return handle of current graphic window.
History
| Версия | Описание |
| 2024.1.0 | Function colormap introduced. |
| 2026.0.0 | Axes handles are now managed as input. |
| Report an issue | ||
| << oбразчики | oбразчики | Using colormaps >> |