%% Plot Multiple Variables Using One Y-Axis
% Create a table from a subset of patient data, using the Weight, Systolic, and Diastolic variables.

load patients
tbl = table(Weight,Systolic,Diastolic);
head(tbl,3)

%
% Create a stacked plot, with Systolic and Diastolic plotted using the same y-axis, and Weight using its own y-axis. First, specify vars as a cell array with two elements. The first element groups "Systolic" and "Diastolic" together in a string array. They are plotted together on a common y-axis. The second element of the cell array is "Weight". It is plotted on its own y-axis.

vars = {["Systolic","Diastolic"],"Weight"}

%

stackedplot(tbl,vars)

%
% Copyright 2018-2021 The MathWorks, Inc.