Side by side boxplots

87 ビュー (過去 30 日間)
Will
Will 2023 年 8 月 18 日
コメント済み: Voss 2023 年 8 月 18 日
Hi Guys,
I've got a .mat file which has two data sets that load in as 35x1 doubles.
I would like to create a graph that has the box plots of each data set next to each other.
I've had a look at the boxplots function on the help centre page and browsed the forums for similar problems, of which there are some, but I am having trouble understanding how to do this.
I thought I could just use boxplot(x, y) but this produces a graph that looks like this:
Any help to get something which looks like this (see below) would be much appreciated.
Note that this is just an example that I found on google but it gives an idea of what I am trying to achieve.
Thank you

採用された回答

Voss
Voss 2023 年 8 月 18 日
編集済み: Voss 2023 年 8 月 18 日
% some random data
x = rand(35,1);
y = 2*rand(35,1)-1;
% make a boxplot for x:
boxplot(x)
% make a boxplot for y, and specify that it belongs at 2 along the x-axis:
hold on
boxplot(y,'Positions',2)
% update axes x-ticks and labels:
set(gca(),'XTick',[1 2],'XTickLabels',{'x','y'})
  2 件のコメント
Will
Will 2023 年 8 月 18 日
Thank you for the help Voss.
Voss
Voss 2023 年 8 月 18 日
You're welcome Will.

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2023 年 8 月 18 日

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by