Plotting statistics for a table

1 view (last 30 days)
Nazar Adamchuk
Nazar Adamchuk on 29 Oct 2021
Answered: Ive J on 29 Oct 2021
Hello,
I have a complex table. An excerpt of it I have put into attachment. it has three regions and three variables.
My goal is to be able to plot such kind of grpah:
The blue markers are the maximum values of each variable per region, the green ones - the minimum values of each variable per each region, the black bar - standard deviation.
So far I have:
locmean = varfun(@mean,Local_Mat_Data,...
'InputVariables',...
{'LocFatigLim_MIN', 'LocSlop_MIN', 'LocCycLim_MIN'},...
'GroupingVariables','Region');
locstd = varfun(@std,Local_Mat_Data,...
'InputVariables',...
{'LocFatigLim_MIN', 'LocSlop_MIN', 'LocCycLim_MIN'},...
'GroupingVariables','Region');
locmin = varfun(@min,Local_Mat_Data,...
'InputVariables',...
{'LocFatigLim_MIN', 'LocSlop_MIN', 'LocCycLim_MIN'},...
'GroupingVariables','Region');
locmax = varfun(@max,Local_Mat_Data,...
'InputVariables',...
{'LocFatigLim_MIN', 'LocSlop_MIN', 'LocCycLim_MIN'},...
'GroupingVariables','Region');
Then I have somesow plot all data of this four tables nicely in three plots into the form of the graph that I have provided in the post. Do you have any alegand solution of plotting the graph?
Thanks!

Accepted Answer

Ive J
Ive J on 29 Oct 2021
Try this, but note that your variables are highly skewed, so you should try boxplot or boxchart (median and IQR instead of mean and SD).
tab = load('example.mat').Local_Mat_Data;
t = groupsummary(tab, 'Region', {'mean', 'min', 'max', 'std'});
capsz = 20;
linew = 1.5;
hold on
plot(t.Region, t.mean_LocCycLim_MIN, 'Marker', '_', 'LineStyle', 'none', 'LineWidth', linew, 'Color', 'k', 'MarkerSize', capsz)
plot(t.Region, t.min_LocCycLim_MIN, 'Marker', '_', 'LineStyle', 'none', 'LineWidth', linew, 'Color', 'g', 'MarkerSize', capsz)
plot(t.Region, t.max_LocCycLim_MIN, 'Marker', '_', 'LineStyle', 'none', 'LineWidth', linew, 'Color', 'b', 'MarkerSize', capsz)
errorbar(t.Region, t.mean_LocCycLim_MIN, t.std_LocCycLim_MIN,'.','Color', 'k', 'LineWidth', linew, 'CapSize', capsz)
h = gca;
h.YGrid = 'on';
h.GridAlpha = 0.5;
h.XLim = [min(tab.Region) - 1, max(tab.Region) + 1];
h.XTick = t.Region;
h.XTickLabel = "Region " + h.XTick;
title('LocCycLim_MIN', 'Interpreter', 'none')
h.Box = 'on';

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!