Boxplot for both x and y axis with different box widths.
35 views (last 30 days)
Show older comments
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.

Accepted Answer
Benjamin Kraus
on 30 Apr 2021
Edited: Benjamin Kraus
on 30 Apr 2021
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));
More Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!