Main Content

StackedAxesProperties Properties

Appearance and behavior of individual axes in stacked plot

StackedAxesProperties properties control the appearance and behavior of individual y-axes in a stacked plot. In a stacked plot, you can plot the variables of a table or timetable, or the columns of a matrix, in separate y-axes, stacked vertically. By changing property values, you can modify certain aspects of the stacked plot.

The stackedplot function returns a StackedLineChart object. In turn, this object has an array of StackedAxesProperties objects, named AxesProperties. To set properties of an individual y-axis, index into AxesProperties and access properties of the corresponding object.

You can use dot notation to query and set properties. For example, change y-limits of the third plot using its YLimits property.

T = readtable("outages.csv");
s = stackedplot(T);
c = s.AxesProperties(3).YLimits
s.AxesProperties(3).YLimits = [0 1e6];

Minimum and maximum y-axis limits, specified as a two-element vector of the form [min max], where max is greater than min. You can specify the limits as numeric, categorical, datetime, or duration values. However, the type of values that you specify must match the type of values along the axis.

You can specify both limits or you can specify one limit and let the axes automatically calculate the other. For an automatically calculated minimum or maximum limit, use -inf or inf, respectively.

Example: s.AxesProperties(3).YLimits = [0 1e6]

Example: s.AxesProperties(3).YLimits = [-inf 1e6]

Example: s.AxesProperties(3).YLimits = [0 inf]

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | categorical | datetime | duration

Linear or log scale for the y-axis, specified as "linear" or "log".

Example: s.AxesProperties(3).YScale = "log"

Legend labels, specified as a string array or cell array of character vectors. If you do not specify labels, then the labels are variable names (for tables and timetables) or "Column N" (for the Nth column of a matrix).

Legends do not display unless the LegendVisible property is set to "on".

Example: s.AxesProperties(1).LegendLabels = ["Label 1","Label 2"]

Location with respect to the axes, specified as one of the location values listed in this table.

ValueDescription
"north"Inside top of axes
"south"Inside bottom of axes
"east"Inside right of axes
"west"Inside left of axes
"northeast"Inside top-right of axes (default for 2-D axes)
"northwest"Inside top-left of axes
"southeast"Inside bottom-right of axes
"southwest"Inside bottom-left of axes

Example: s.AxesProperties(2).LegendLocation = "southeast"

State of legend visibility, specified as "on" or "off". Set LegendVisible to "on" to display the legend or "off" to hide the legend.

Example: s.AxesProperties(3).LegendVisible = "on"

Indicator to collapse the legend, specified as "on" or "off". If the stacked plot comes from multiple tables or timetables, set CollapseLegend to "on" to enable legend collapsing behavior or "off" to disable.

Example: s.AxesProperties(3).CollapseLegend = "on"

Version History

Introduced in R2018b