yregion
Shades a horizontal band between two y values.
Category: Graphics > Formatting and Annotation
Syntax
yregion(y1, y2)
Shades the band from y1 to y2 over the full width of the axes.
yregion(y1, y2, Name, Value)
Sets properties such as 'FaceColor' and 'FaceAlpha'.
yr = yregion(___)
Returns the region object.
Description
The band stays attached to its y values, so it fills the whole plot width whatever the limits. It does not change the automatic limits. It is used to show a tolerance range, a safe operating band or a level of interest.
The vertical counterpart is xregion.
Input arguments
y1, y2- Edges of the band along the y-axis. Vectors of equal length draw several bands.
Output arguments
yr- Constant region object, class
matlab.graphics.chart.decoration.ConstantRegion, with the propertyValueholding[y1 y2].
Example
Highlight a tolerance band
y = [3 5 4 6 2 7];
plot(y)
r = yregion(3, 5, 'FaceColor', 'g');
r.Value
Output
ans = 1×2
3 5