How to combine boxplots from Anova into subplots
1 回表示 (過去 30 日間)
古いコメントを表示
Frederick Awuah-Gyasi
2023 年 5 月 16 日
コメント済み: Frederick Awuah-Gyasi
2023 年 5 月 17 日
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 件のコメント
採用された回答
Askic V
2023 年 5 月 16 日
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')
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!