Skip to Main Content Skip to Search
Product Documentation

stairs - Stairstep graph

Example of stairs function output

Alternatives

To graph selected variables, use the Plot Selector in the Workspace Browser, or use the Figure Palette Plot Catalog. Manipulate graphs in plot edit mode with the Property Editor. For details, see Plotting Tools — Interactive Plotting in the MATLAB Graphics documentation and Creating Graphics from the Workspace Browser in the MATLAB Desktop Tools documentation.

Syntax

stairs(Y)
stairs(X,Y)
stairs(...,LineSpec)
stairs(...,'PropertyName',propertyvalue)
stairs(axes_handle,...)
h = stairs(...)
[xb,yb] = stairs(Y,...)

Description

Stairstep graphs are useful for drawing time-history graphs of digitally sampled data.

stairs(Y) draws a stairstep graph of the elements of Y, drawing one line per column for matrices. The axes ColorOrder property determines the color of the lines.

When Y is a vector, the x-axis scale ranges from 1 to length(Y). When Y is a matrix, the x-axis scale ranges from 1 to the number of rows in Y.

stairs(X,Y) plots the elements in Y at the locations specified in X.

X must be the same size as Y or, if Y is a matrix, X can be a row or a column vector such that

length(X) = size(Y,1)

stairs(...,LineSpec) specifies a line style, marker symbol, and color for the graph. (See LineSpec for more information.)

stairs(...,'PropertyName',propertyvalue) creates the stairstep graph, applying the specified property settings. See Stairseries properties for a description of properties.

stairs(axes_handle,...) plots into the axes with the handle axes_handle instead of into the current axes object (gca).

h = stairs(...) returns the handles of the stairseries objects created (one per matrix column).

[xb,yb] = stairs(Y,...) does not draw graphs, but returns vectors xb and yb such that plot(xb,yb) plots the stairstep graph.

Examples

Create a stairstep plot of a sine wave.

x = linspace(-2*pi,2*pi,40);
stairs(x,sin(x))

See Also

bar | hist | stem

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS