Main Content

修改条形图的基线

此示例演示如何修改条形图基线的属性。

创建一个四列矩阵的条形图。bar 函数为矩阵的每一列创建一个条形序列。将这四个条形序列返回为 b

Y = [5, 4, 3, 5;
     3, 6, 3, 1;
     4, 3, 5, 4];
b = bar(Y);

Figure contains an axes object. The axes object contains 4 objects of type bar.

图表中的所有条形序列具有相同的基线。通过设置任一条形序列的 BaseValue 属性将基线的值更改为 2。使用圆点表示法设置属性。

b(1).BaseValue = 2;

Figure contains an axes object. The axes object contains 4 objects of type bar.

将基线更改为粗的红色点线。

b(1).BaseLine.LineStyle = ':';
b(1).BaseLine.Color = 'red';
b(1).BaseLine.LineWidth = 2;

Figure contains an axes object. The axes object contains 4 objects of type bar.

另请参阅

|