Main Content

getColorbar

Class: matlab.graphics.chartcontainer.mixin.Colorbar
Namespace: matlab.graphics.chartcontainer.mixin

Get colorbar object for colorbar mixin subclass

Syntax

cb = getColorbar(obj)

Description

cb = getColorbar(obj) returns the colorbar for a chart object that inherits from the matlab.graphics.chartcontainer.mixin.Colorbar class.

Input Arguments

expand all

Object of the class that inherits from the matlab.graphics.chartcontainer.mixin.Colorbar class.

Output Arguments

expand all

Colorbar object for the chart.

Attributes

Protectedtrue

To learn about attributes of methods, see Method Attributes.

Examples

expand all

Create a setup method in your class definition file. Within that method, call getColorbar to get the colorbar object c. Then remove the ticks from the colorbar, and set its location to 'southoutside'.

classdef ColorbarChart < matlab.graphics.chartcontainer.ChartContainer & ...
        matlab.graphics.chartcontainer.mixin.Colorbar
    
    properties
        % ...
    end
    
    methods(Access = protected)
        function setup(obj)
            % Make colorbar visible
            obj.ColorbarVisible = 'on';
            
            % Get the colorbar, remove the ticks, and set the location
            cb = getColorbar(obj);
            cb.Ticks = [];
            cb.Location = 'southoutside';
        end
        function update(obj)
            % ...
        end
    end
end

Version History

Introduced in R2019b