Plotting statistics for a table

1 回表示 (過去 30 日間)
Nazar Adamchuk
Nazar Adamchuk 2021 年 10 月 29 日
回答済み: Ive J 2021 年 10 月 29 日
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!

採用された回答

Ive J
Ive J 2021 年 10 月 29 日
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';

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by