Back to Data Visualization

colorbar

Add colorbar to current chart

Syntax

colorbar
colorbar('off')
colorbar('location')
c = colorbar

Description

Displays a colorbar showing the color scale for the current heatmap, mesh, or surf plot. Supports location options ('eastoutside', 'westoutside', 'northoutside', 'southoutside') and can return a handle for further property manipulation using set().

Parameters

NameDescription
location(optional)Location string: 'eastoutside' (default), 'westoutside', 'northoutside', 'southoutside', or 'off'

Returns

Colorbar handle (when assigned to variable)

Examples

Try It
>> imagesc(peaks(30));
colorbar
Try It
>> surf(peaks(30));
colorbar('southoutside')
Try It
>> imagesc(rand(20));
c = colorbar;
set(c, 'Title', 'Values')
Try It
>> mesh(peaks);
colorbar('off')

See Also