yline

Add one or more horizontal lines in the current axes or a specified axes.

Syntax

h = yline(y)

h = yline(..., property, value, ...)

h = yline(hAxes, ...)

Inputs

y
Constant point y of the horizontal line.
Type: double | integer
Dimension: scalar | vector
property
Properties that control the appearance or behavior of the graphics object.
Type: string
Dimension: scalar
value
Value of the properties.
Type: double | integer | string
Dimension: scalar | vector
hAxes
Axis handle.
Type: double
Dimension: scalar

Outputs

h
Handle of the line graphics object.

Examples

Simple yline example:
clf;
        h = yline(2);
      
Figure 1. Horizontal line at y = 2
Create horizontal lines and set properties example:
clf;
          x=[0:0.1:3*pi];
          plot(x, sin(x)); 
          h = yline([-1;1],'color','r','linestyle','--');
          ylim([-1.5 1.5])
        
Figure 2. Create 2 lines and set properties

Comments

If there is no axis, one will be created first. If y is an Mx1 matrix then M horizontal lines will be created.