Main Content

getLegend

クラス: matlab.graphics.chartcontainer.mixin.Legend
名前空間: matlab.graphics.chartcontainer.mixin

凡例 mixin サブクラスの legend オブジェクトを取得

R2019b 以降

構文

lgd = getLegend(obj)

説明

lgd = getLegend(obj) は、matlab.graphics.chartcontainer.mixin.Legend クラスから継承するチャート オブジェクトの凡例を返します。

入力引数

すべて展開する

matlab.graphics.chartcontainer.mixin.Legend クラスから継承するクラスのオブジェクト。

出力引数

すべて展開する

チャートの Legend オブジェクト。

属性

Protectedtrue

メソッドの属性の詳細については、メソッドの属性を参照してください。

すべて展開する

クラス定義ファイルで setup メソッドを作成します。そのメソッド内で、getLegend を呼び出して legend オブジェクト lgd を取得します。次に、テキストの色、ボックス エッジの色、ボックスのライン幅を変更します。

classdef ConfigLegendChart < matlab.graphics.chartcontainer.ChartContainer & ...
        matlab.graphics.chartcontainer.mixin.Legend
    
    properties
        % ...
    end
    
    methods(Access = protected)
        function setup(obj)
            % Make legend visible
            obj.LegendVisible = 'on';
            
            % Get legend and set text color, edge color, and line width
            lgd = getLegend(obj);
            lgd.TextColor = [.3 .3 .3];
            lgd.EdgeColor = [.8 .8 .8];
            lgd.LineWidth = .7;
        end
        function update(obj)
            % ...
        end
    end
end

バージョン履歴

R2019b で導入