How to plot multiple multcompare plots from anova
26 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
It doesn't work when I try to use tiledlayout to make a combined plot
% Loading data
y = [52.7 57.5 45.9 44.5 53.0 57.0 45.9 44.0]';
g1 = [1 2 1 2 1 2 1 2];
g2 = {'hi';'hi';'lo';'lo';'hi';'hi';'lo';'lo'};
g3 = {'may';'may';'may';'may';'june';'june';'june';'june'};
% For loop with subplot
for n = 1:4
subplot(2,2,n)
hold on
[~,~,stats] = anovan(y,{g1 g2 g3},'model','interaction','varnames',{'g1','g2','g3'});
results = multcompare(stats,'Dimension',[1 2]);
hold off
end
And tiledlayout also doesn't work
tiledlayout('flow')
nexttile
[~,~,stats] = anovan(y,{g1 g2 g3},'model','interaction','varnames',{'g1','g2','g3'});
results = multcompare(stats,'Dimension',[1 2]);
nexttile
[~,~,stats] = anovan(y,{g1 g2 g3},'model','interaction','varnames',{'g1','g2','g3'});
results = multcompare(stats,'Dimension',[1 2]);
0 commentaires
Réponse acceptée
Walter Roberson
le 27 Jan 2020
multcompare() calls meansgraph(), which always unconditionally does a clf() which erases the entire current figure.
Therefore to plot multiple such graphs on the same figure, you are going to need to provide a figure for multcompare() to scribble into, and then you are going to have to extract the axes from the figure and move it to the desired target location.
However, there is the hidden difficulty that the graphs are interactive, each line having a buttondownfcn callback. To support that, the axes is given UserData and also the figure is given UserData as well. If you had more than one kind of multcompare, such as mixing anova1 with kruskalwallis then you would have a conflict when you merged the axes into one figure, but you should be okay as long as they are all for the same kind of graph.
4 commentaires
Barbab
le 3 Oct 2023
Hello, I am trying to do the same, unfortunately the code you provided above for the multcompare plots is not working in my case. It says "Error using matlab.graphics.axis. Axes/set Invalid or deleted object." Could you suggest another solution?
Is there any easy way to get the data directly from multcompare and to plot it directly how I would like it to be?
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!