Main Content

StackedAxesProperties 属性

堆叠图中各轴的外观和行为

StackedAxesProperties 属性控制堆叠图中各个 y 轴的外观和行为。在堆叠图中,您可以在垂直堆叠的单独 y 轴中绘制表或时间表的变量或矩阵的列。通过更改属性值,您可以修改堆叠图的特定方面。

stackedplot 函数返回 StackedLineChart 对象。此对象又包含 StackedAxesProperties 对象数组,名为 AxesProperties。要设置单个 y 轴的属性,请对 AxesProperties 进行索引并访问对应对象的属性。

您可以使用圆点表示法查询和设置属性。例如,使用第三个图的 YLimits 属性更改其 y 范围。

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

最小和最大 y 坐标轴范围,指定为 [min max] 形式的二元素向量,其中 max 大于 min。您可以将范围指定为数字、分类、日期时间或持续时间值。但您指定的值类型必须与坐标轴上的值类型匹配。

您可以指定这两个范围,也可以指定一个范围而让坐标区自动计算另一个范围。对于自动计算的最小值或最小值范围,分别使用 -infinf 来表示。

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

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

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

数据类型: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | categorical | datetime | duration

y 轴的线性或对数刻度,指定为 "linear""log"

示例: s.AxesProperties(3).YScale = "log"

图例标签,指定为字符串数组或字符向量元胞数组。如果未指定标签,则标签为变量名(对于表和时间表)或 "Column N"(对于矩阵的第 N 列)。

除非 LegendVisible 属性设置为 "on",否则不会显示图例。

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

相对于坐标区的位置,指定为下表中所列的位置值之一。

描述
"north"坐标区中的顶部
"south"坐标区中的底部
"east"坐标区中的右侧区域
"west"坐标区中的左侧区域
"northeast"坐标区中的右上角(二维坐标区的默认值)
"northwest"坐标区中的左上角
"southeast"坐标区中的右下角
"southwest"坐标区中的左下角

示例: s.AxesProperties(2).LegendLocation = "southeast"

图例可见性的状态,指定为 "on""off"。将 LegendVisible 设置为 "on" 会显示图例,设置为 "off" 会隐藏图例。

示例: s.AxesProperties(3).LegendVisible = "on"

折叠图例的指示符,指定为 "on""off"。如果堆叠图来自多个表或时间表,可将 CollapseLegend 设置为 "on" 以启用图例折叠行为,或设置为 "off" 以禁用该行为。

示例: s.AxesProperties(3).CollapseLegend = "on"

版本历史记录

在 R2018b 中推出