%% Plot Mean over Box Charts
% Create box charts, and plot the mean values over the box charts by using hold on.
% Load the patients data set. Convert SelfAssessedHealthStatus to an ordinal categorical variable because the categories Poor, Fair, Good, and Excellent have a natural order.

load patients
healthOrder = {'Poor','Fair','Good','Excellent'};
SelfAssessedHealthStatus = categorical(SelfAssessedHealthStatus, ...
    healthOrder,'Ordinal',true);

% Group the patients according to their self-assessed health status, and find the mean patient weight for each group.

meanWeight = groupsummary(Weight,SelfAssessedHealthStatus,'mean');

% Compare the weights for each group of patients by using box charts. Plot the mean weights over the box charts.

boxchart(SelfAssessedHealthStatus,Weight)
hold on
plot(meanWeight,'-o')
hold off
legend(["Weight Data","Weight Mean"])

% Copyright 2019 The MathWorks, Inc.