stackedplot

Plots several variables in vertically stacked axes that share the x-axis.

Category: Language Fundamentals > Data Types

Syntax

stackedplot(tbl)

Plots every variable of a table or timetable in its own axes. A timetable uses its row times as x.

stackedplot(X, Y)

Plots the columns of Y against X, one axes per column.

Description

Variables with different units or ranges are easier to compare when each has its own y-axis but all share the same horizontal axis. Each stacked axes is labeled with the variable name. The plot appears below the code in a live script.

Input arguments

tbl
Table or timetable.
X, Y
Numeric data; Y may be a matrix.

Output arguments

s
Optional handle to the stacked plot object.

Example

TT = timetable(seconds([1;2;3]), [1;2;3], [3;2;1], 'VariableNames', {'up','down'});
stackedplot(TT)

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

See also

plot subplot tiledlayout timetable