Plotting table results from grpstats

5 次查看(过去 30 天)
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

采纳的回答

Antoni Garcia-Herreros
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 个评论
Antoni Garcia-Herreros
Try
PAM1stats = grpstats(PAM1,["DHW","SHADE"],["min","max","mean","std"], "DataVars",{'FVFM','YIELD','NSV'});
Sophia
Sophia 2023-5-10
Perfect, just needed square brackets. Thanks!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by