{
"title": "colorbar",
"category": "plotting",
"keywords": [
"colorbar",
"color scale",
"image colorbar",
"surface colorbar",
"matlab colorbar"
],
"summary": "Show or hide colorbars for images, surfaces, contours, and MATLAB `colorbar` workflows.",
"requires_feature": null,
"tested": {
"unit": "builtins::plotting::cmds"
},
"description": "`colorbar` toggles the visibility of the color scale associated with the current axes. In RunMat it is subplot-local and is most often used with `imagesc`, `image`, `surf`, `contourf`, and related colormap-driven visualizations.",
"behaviors": [
"`colorbar on` enables the colorbar for the current axes.",
"`colorbar off` disables the colorbar for the current axes.",
"Calling `colorbar` with no argument toggles the current colorbar state.",
"Colorbar visibility is subplot-local and does not automatically affect other axes."
],
"examples": [
{
"description": "Show a colorbar for a scaled image",
"input": "[X, Y] = meshgrid(linspace(-3, 3, 60), linspace(-3, 3, 60));\nA = sin(X) .* cos(Y);\nimagesc(A);\ncolorbar on;"
},
{
"description": "Use colorbars independently across subplots",
"input": "[X, Y] = meshgrid(linspace(-3, 3, 40), linspace(-3, 3, 40));\nZ = sin(X) .* cos(Y);\nsubplot(1, 2, 1);\ncontourf(X, Y, Z);\ncolorbar on;\nsubplot(1, 2, 2);\nsurf(X, Y, Z);\ncolorbar off;"
}
],
"links": [
{ "label": "colormap", "url": "./colormap" },
{ "label": "imagesc", "url": "./imagesc" },
{ "label": "surf", "url": "./surf" },
{ "label": "contourf", "url": "./contourf" }
],
"source": {
"label": "`crates/runmat-runtime/src/builtins/plotting/ops/cmds.rs`",
"url": "https://github.com/runmat-org/runmat/blob/main/crates/runmat-runtime/src/builtins/plotting/ops/cmds.rs"
}
}