Don't want box plots to overlap...
16 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Mario Malic
2021 年 6 月 8 日
subplot(1,2,1)
boxplot(MC_participant_Mean)
subplot(1,2,2)
boxplot(MC_participant_Med)
採用された回答
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');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/646280/image.jpeg)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!