Plotting table results from grpstats

4 views (last 30 days)
I would like to display grpstats for all three variables of FVFM, YIELD and NSV, DataVars only allows me to do this for one variable
Is it possible to plot select results from the table and display as an error bar plot (mean and std), for example just the results for 0_0, 4_0 and 6_0? I want to make a tiled plot that separates the results by treatment which is why I dont want to plot all the results at once
filename = 'PAM1'
PAM1 = readtable (filename)
PAM1stats = grpstats(PAM1,["DHW","SHADE"],["min","max","mean","std"], "DataVars","FVFM") %ONLY ONE VARIABLE AT ONCE

Accepted Answer

Antoni Garcia-Herreros
Antoni Garcia-Herreros on 10 May 2023
Hello Sophia,
You could try something like this:
close all
load('PAM1.mat')
PAM1stats = grpstats(PAM1,["DHW","SHADE"],["min","max","mean","std"], "DataVars","FVFM"); %ONLY ONE VARIABLE AT ONCE
Data2Plot=PAM1stats{[1 4 7],6:7}; % Select the data you want to plot. In this case 0_0 , 4_0 and 6_0
p=plot([1,2,3],Data2Plot(:,1)','o','LineWidth',2,'MarkerFaceColor','k','MarkerEdgeColor','k');
hold on
e=errorbar([1,2,3],Data2Plot(:,1),-Data2Plot(:,2),Data2Plot(:,2),'LineWidth',1.5,'LineStyle','none','Color','k');
e(1).CapSize=18;
ax=gca;
ax.XLim=[0.5 3.5];
ax.XTick=[1 2 3];
ax.XTickLabel={'0-0';'4-0';'6-0'};
ax.FontName='Arial';
ax.FontSize=13;
ax.FontWeight='bold';
ax.TickDir='out';
ax.Box='off';
  3 Comments
Antoni Garcia-Herreros
Antoni Garcia-Herreros on 10 May 2023
Try
PAM1stats = grpstats(PAM1,["DHW","SHADE"],["min","max","mean","std"], "DataVars",{'FVFM','YIELD','NSV'});
Sophia
Sophia on 10 May 2023
Perfect, just needed square brackets. Thanks!

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!