필터 지우기
필터 지우기

Don't want box plots to overlap...

조회 수: 19 (최근 30일)
Wesser
Wesser 2021년 6월 7일
댓글: Wesser 2021년 6월 8일
Hi,
I'm trying to get two boxplots to plot next to each other and NOT overlap (as is the case with the below code). I would also like there to be a label at the bottom of each boxplot indicating if it's the median or the mean boxplot. How would I go about this?
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%Boxplot of mean/median start of exposure for ALL study participant
figure
box_mean=boxplot(MC_participant_Mean);
hold on
box_med=boxplot(MC_participant_Med);
ylabel('Start of PFHxS exposure after 1970 (6mo)')
title('Distribution of exposure for all study participant (MC=10,000)')
Many thanks!!
  댓글 수: 3
Wesser
Wesser 2021년 6월 7일
This only returns one boxplot. I'm looking to have two (one for mean, one for median) side by side. Any other suggestions.
Thanks for your time.
Mario Malic
Mario Malic 2021년 6월 8일
subplot(1,2,1)
boxplot(MC_participant_Mean)
subplot(1,2,2)
boxplot(MC_participant_Med)

댓글을 달려면 로그인하십시오.

채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 6월 8일
You only need to use the boxplot function once. Combine the data in a matrix. You'll get a box plot for each column of data and they will be side-by-side and non-overlapping:
d1 = rand(10,1);
d2 = rand(10,1);
d = [d1 d2];
boxplot(d, 'labels', {'Left Box' 'Right Box'});
title('Your title');

추가 답변 (0개)

태그

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by