How to create two-dimensional boxplots

조회 수: 49 (최근 30일)
Tom Rüther
Tom Rüther 2023년 1월 16일
댓글: Tom Rüther 2023년 1월 16일
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:
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

채택된 답변

Kevin Holly
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
Tom Rüther
Tom Rüther 2023년 1월 16일
Dear Kevin,
thank you for this very nice and easy solution!
Best regards,
Tom

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Constantino Carlos Reyes-Aldasoro
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
  댓글 수: 1
Tom Rüther
Tom Rüther 2023년 1월 16일
Dear Constantino,
Thank you for your quick reply, unfortunately this does not work for the desired plot as I would like to display the information in x-direction as well.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by