%% Plot Timetable Variables
% Read data from a spreadsheet to a timetable. (Read any text data it contains into string arrays). The first variable that contains dates and times, OutageTime, provides the row times for the timetable. Display the first five rows.

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

%
% Sort the timetable so that its row times are in order. The row times of a timetable do not need to be in order. However, if you use the row times as the x-axis of a plot, then it is better to ensure the timetable is sorted by its row times.

tbl = sortrows(tbl);
head(tbl,5)

%
% Create a stacked plot of data from tbl. The row times, OutageTime, provide the values along the x-axis. The stackedplot function plots the values from the Loss, Customers, and RestorationTime variables, with each variable plotted along its own y-axis. However, the plot does not include the Region and Cause variables because they contain data that cannot be plotted.

stackedplot(tbl)

%
% Copyright 2018-2021 The MathWorks, Inc.