How to create two-dimensional boxplots
31 次查看(过去 30 天)
显示 更早的评论
Hey all,
I would like to create a two-dimensional boxplot. So far I only managed to create 1D Boxplots with fixed x-value using boxchart. The result should be something like the below image:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1265425/image.png)
On stackoverflow I found a solution for R and Python (matlplotlib), unfortunately I didn't find anything for Matlab.
R-solution
Python (matplotlib) solution
I would be happy if someone has a clever idea for the solution. Thanks in advance and best regards,
Tom
0 个评论
采纳的回答
Kevin Holly
2023-1-16
编辑:Kevin Holly
2023-1-16
x = rand(1,30);
y = rand(1,30);
tiledlayout(1,2)
nexttile
scatter(x,y,'filled','r');
nexttile
boxchart(median(y)*ones(size(x)),x)
hold on
boxchart(median(x)*ones(size(y)),y,"Orientation","horizontal")
更多回答(1 个)
Constantino Carlos Reyes-Aldasoro
2023-1-16
Have a look at this code:
It describes how to do 3D boxplots, if you only have one grouping, it would go down to 2D
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1265460/image.png)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!