%% Reorder Variables
% Read a timetable from file and display its first three rows.

tbl = readtimetable("outages.csv","TextType","string");
tbl = sortrows(tbl);
head(tbl,3)

%
% Reorder the variables by specifying them in an order that differs from their order in the table. For example, RestorationTime is the last variable in the timetable that can be plotted. By default, stackedplot places it at the bottom of the plot. But you can reorder the variables to put RestorationTime at the top.

stackedplot(tbl,["RestorationTime","Loss","Customers"])

%
% There are also other ways to reorder the variables.
% Specify them by their numeric order in the table: stackedplot(tbl,[4 2 3]);
% Return a StackedLineChart object and reorder the values in its DisplayVariables property: s = stackedplot(tbl); s.DisplayVariables = ["RestorationTime","Loss","Customers"]
% Copyright 2018-2021 The MathWorks, Inc.