Modify Baseline of Bar Graph

This example shows how to modify properties of the baseline of a bar graph.

Create a bar graph of a four-column matrix. The bar function creates a bar series for each column of the matrix. Return the four bar series as b.

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

All bar series in a graph share the same baseline. Change the value of the baseline to 2 by setting the BaseValue property for any of the bar series.

Note: Starting in R2014b, you can use dot notation to set properties. If you are using an earlier release, use the set function instead, such as set(b(1),'BaseValue',2).

b(1).BaseValue = 2;

Change the baseline to a thick, red dotted line.

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

See Also

|