how can i plot overlapping dendrograms with manovacluster or similar manova output ?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have reasson to try to compare mANOVA results in different ways (e.g, for comparing mahalanobis distances at different times) and plot multiple manovacluster output ONTO the same axes. The latter part is the problem.
What seems to happen is that the call to manovacluster always populates a new figure whenever hold on is true.
e.g a MWE
load carbig
X = [MPG Acceleration Weight Displacement];
[d,p,stats] = manova1(X,Origin);
h1 = manovacluster(stats); %
hold on;
X2 = [flipud(MPG) Acceleration flipud(Weight) Displacement];
[~,~,stats2] = manova1(X2,Origin)
h2 = manovacluster(stats2); % This will ALWAYS be in a separate figure than the figure for hi
an even more-minimal working example is this... even in an empty figure, a new figure is generated if hold on is true.
figure;
hold on;
X2 = [flipud(MPG) Acceleration flipud(Weight) Displacement];
[~,~,stats2] = manova1(X2,Origin)
h2 = manovacluster(stats2);
I suspect that dendrogram underlying the whole thing reqires new axes every time, and refuses to inherit an axis or something. But the axes (the horizontal one, at least) here will be identical. I'm unable to find any community Q/A or examples of overlapping dendograms, and it doesn't seem too crazy to want to do this. Any known workarounds?
(I suspect a simple solution combinng h1 = [h1; h2] into a single giant array of line handles, but i'm not sure what to do with them after than.)
0 Commenti
Risposte (1)
Yash
il 4 Gen 2024
Modificato: Yash
il 4 Gen 2024
Hello,
I understand that you are interested in comparing mANOVA results by plotting multiple "manovacluster" output onto the same axes. You are correct that "manovacluster" has internal implementation in such a way that it adds new figure for each dendrogram.
I have found a workaround to plot both dendrograms on the same axes by utilizing the outputs "h1" and "h2". Note that, "h1" and "h2" are line arrays and you need to extract each line from them and plot them together on a new figure. Given below is a working example of the same:
% Your code
load carbig
X = [MPG Acceleration Weight Displacement];
[d,p,stats] = manova1(X,Origin);
h1 = manovacluster(stats); %
hold on;
X2 = [flipud(MPG) Acceleration flipud(Weight) Displacement];
[~,~,stats2] = manova1(X2,Origin);
h2 = manovacluster(stats2); % This will ALWAYS be in a separate figure than the figure for hi
hold off
% Code to plot the lines on the same axes, on a new figure
f = figure;
ax = axes;
hold on
for i=1:length(h1)
plot(h1(i).XData,h1(i).YData,'b');
end
for i=1:length(h2)
plot(h2(i).XData,h2(i).YData,'r'); %Use different Color for both the dendrograms
end
Hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Repeated Measures and MANOVA in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!