Insert extra line in figure only in certain boxplots

조회 수: 6 (최근 30일)
Richard
Richard 2024년 3월 28일
댓글: Voss 2024년 3월 28일
Hello,
I've got the following code:
A = rand(4,1);
B = rand(4,1);
f = figure;
boxplot([A,B],Whisker=100,Labels={'Var A','Var B'},LabelOrientation="inline");
title('Boxplot')
yline(0.4);
It draws the yline completely all over both plots, but I want it only in the area of plot A and want to draw another a yline of different value in the Area of plot B. How do I do this?
Thanks a lot in advance!

채택된 답변

Voss
Voss 2024년 3월 28일
A = rand(4,1);
B = rand(4,1);
f = figure;
boxplot([A,B],Whisker=100,Labels={'Var A','Var B'},LabelOrientation="inline");
title('Boxplot')
A_val = 0.4;
B_val = 0.6;
line([0 1.5],A_val([1 1]),'Color','k')
line([1.5 3],B_val([1 1]),'Color','k')
  댓글 수: 2
Richard
Richard 2024년 3월 28일
Looks so easy as soon as the code is there.
Thanks a lot :)
Voss
Voss 2024년 3월 28일
You're welcome!

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

추가 답변 (0개)

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by