How to combine boxplots from Anova into subplots
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Frederick Awuah-Gyasi
le 16 Mai 2023
Commenté : Frederick Awuah-Gyasi
le 17 Mai 2023
I have three plots I want to combine this way but each anova1 produces 2 figures : a table and box plot and i'm not quite getting the box plots in the subplot as desired.
How do I combine the box plots into subplots.?
y = a(:,{'GRP_1','GRP_2','GRP_3','GRP_4'})
[p,tbl,stats] = anova1(y{:,:})
xlabel('xlabel')
ylabel('ylabel')
subplot(3,2,3)
y = b(:,{'GRP_1','GRP_2','GRP_3','GRP_4'})
[p,tbl,stats] = anova1(y{:,:})
xlabel('xlabel')
ylabel('ylabel')
subplot(3,3,3)
y = c(:,{'GRP_1','GRP_2','GRP_3','GRP_4'})
[p,tbl,stats] = anova1(y{:,:})
xlabel('xlabel')
ylabel('ylabel')
0 commentaires
Réponse acceptée
Askic V
le 16 Mai 2023
Can the following example give you an ide how to solve the problem?
clear;clc;close all;
y1 = meshgrid(1:5);
%rng default; % For reproducibility
y1 = y1 + normrnd(0,1,5,5);
[p_1,tbl_1,stats_1] = anova1(y1)
y2 = meshgrid(1:5);
%rng default; % For reproducibility
y2 = y2 + normrnd(0,1,5,5);
[p_2,tbl_2,stats_2] = anova1(y2);
y3 = meshgrid(1:5);
%rng default; % For reproducibility
y3 = y3 + normrnd(0,1,5,5);
[p_3,tbl_3,stats_3] = anova1(y3)
h1 = figure(2);
h2 = figure(4);
h3 = figure(6);
% Create a new figure with subplots
figure
subplot(3, 1, 1)
% Copy the first figure into the first subplot
copyobj(allchild(get(h1, 'CurrentAxes')), gca)
title('Copied boxplot 1')
% Create the second subplot
subplot(3, 1, 2)
% Copy the second figure into the second subplot
copyobj(allchild(get(h2, 'CurrentAxes')), gca)
title('Copied boxplot 2')
% Create the third subplot
subplot(3, 1, 3)
% Copy the second figure into the second subplot
copyobj(allchild(get(h3, 'CurrentAxes')), gca)
title('Copied boxplot 3')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!