Main Content

getLegend

Class:matlab.graphics.chartcontainer.mixin.Legend
Package:matlab.graphics.chartcontainer.mixin

Get legend object for legend mixin subclass

Syntax

lgd = getLegend(obj)

Description

lgd= getLegend(obj)returns the legend for a chart object that inherits from thematlab.graphics.chartcontainer.mixin.Legendclass.

Input Arguments

expand all

tha对象的类t inherits from thematlab.graphics.chartcontainer.mixin.Legendclass.

Output Arguments

expand all

Legendobject for the chart.

Attributes

Protected true

To learn about attributes of methods, seeMethod Attributes.

Examples

expand all

创建一个setupmethod in your class definition file. Within that method, callgetLegendto get the legend objectlgd. Then change the text color, box edge color, and box line width.

classdefConfigLegendChart < matlab.graphics.chartcontainer.ChartContainer &...matlab.graphics.chartcontainer.mixin.Legendproperties% ...endmethods(Access = protected)functionsetup(obj)% Make legend visibleobj.LegendVisible ='on';% Get legend and set text color, edge color, and line widthlgd = getLegend(obj); lgd.TextColor = [.3 .3 .3]; lgd.EdgeColor = [.8 .8 .8]; lgd.LineWidth = .7;endfunctionupdate(obj)% ...endendend
Introduced in R2019b