Boxplot for both x and y axis with different box widths.

71 ビュー (過去 30 日間)
Gechang Cao
Gechang Cao 2021 年 4 月 30 日
コメント済み: Gechang Cao 2021 年 5 月 1 日
How can we make a boxplot like the one below for both x and y data (the box widths of each group that are x-data related are different). I tried boxplot(X,Y, group) but it did not work.
boxplot for x- and y-data
  4 件のコメント
Adam Danz
Adam Danz 2021 年 4 月 30 日
編集済み: Adam Danz 2021 年 4 月 30 日
I missed that since BoxWidth is not mentioned on the documentation page for boxchart, however it is listed in the properties page.
Thanks, Benjamin.
Gechang Cao
Gechang Cao 2021 年 5 月 1 日
Thanks for your nice suggestions! boxchart works

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

採用された回答

Benjamin Kraus
Benjamin Kraus 2021 年 4 月 30 日
編集済み: Benjamin Kraus 2021 年 4 月 30 日
The boxplot command creates a group of lines, so if you wanted to adjust the box widths you would need to manually adjust the XData properties on each line to move them to the desired locations.
The better alternative is to use the new boxchart command. The object created by the the boxchart command has a BoxWidth property, but I suspect you won't need it, because even when you specify x values, the boxes created by the boxchart command have uniform widths.
boxchart(randn(1000,1), 'BoxWidth', 0.3);
or
boxchart(randi(10,1000,1),randn(1000,1));
  4 件のコメント
Adam Danz
Adam Danz 2021 年 4 月 30 日
Thanks for the explanation, Benjamin.
I wonder what the logic is in converting numeric inputs to categorical under one syntax but not the other.
Gechang Cao
Gechang Cao 2021 年 5 月 1 日
Thank you very much! Cool, the box widths now are controlled by some numbers. I tried some means but did not make it. The locations of x-data are also controlled by the real values not by even distance. Thanks a lot! This is really cool!!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by