How to combine boxplots from Anova into subplots
조회 수: 3 (최근 30일)
이전 댓글 표시
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!