Use patch() with boxplot

조회 수: 7 (최근 30일)
daniel125
daniel125 2023년 10월 24일
댓글: daniel125 2023년 10월 25일
Hi
I have a boxplot and want to color the chart area behind it.
How it that possible?
I am using patch und boxchart right now. But the boxplot overrides the patch, and if I use the patch after the boxplot its overlaying the boxplot.
I simply need a colorized area below a yline. maybe there is a different way to do so.
greetings

답변 (1개)

Walter Roberson
Walter Roberson 2023년 10월 24일
fill(rand(1,5)*3, rand(1,5)*sqrt(2), 'g');
hold on
boxplot(rand(5,3))
hold off
  댓글 수: 3
Rik
Rik 2023년 10월 24일
편집: Rik 2023년 10월 24일
Perhaps the OP doesn't have the stats toolbox, and therefore needs the boxchart function. The boxchart function converts the x-axis to categorical, so you need to massage the inputs a bit.
fill(rand(1,5)*3, rand(1,5)*sqrt(2), 'g');
hold on
ydata = rand(5,3);
xdata = ( 1:size(ydata,2) ).*ones(size(ydata)); % use implicit expansion
boxchart(xdata(:),ydata(:))
hold off
daniel125
daniel125 2023년 10월 25일
Thanks. You are right, I don't have that toolbox.
I also had to switch from categorical xaxis for the boxchart
xdata = ( 1:size(ydata,2) ).*ones(size(ydata)); % use implicit expansion
helped a lot

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

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by