stairs

Plots data as a stairstep graph, holding each value until the next point.

Category: Graphics > 2-D and 3-D Plots

Syntax

stairs(Y)

Plots the values of Y against their index.

stairs(X, Y)

Plots Y against X.

stairs(___, LineSpec)

Sets color, marker and line style.

h = stairs(___)

Also returns the handles of the stair objects.

Description

Between two points the curve stays flat at the value of the earlier one and jumps at the next x position. This matches a sampled or digital signal: a quantity that is constant between updates, such as a zero-order-hold output or a cumulative count.

Input arguments

X, Y
Vectors or matrices of coordinates. For a matrix Y, each column is drawn as a separate stairstep.

Output arguments

h
Handles of the stair objects.

Example

Sampled sine as steps

x = 0:6;
stairs(x, sin(x))
grid on

In the app, the figure is drawn below the code.

See also

stem plot bar area