Plotting statistics for a table

조회 수: 3(최근 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개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by