Insert extra line in figure only in certain boxplots

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!

 Accepted Answer

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 Comments

Looks so easy as soon as the code is there.
Thanks a lot :)

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Release

R2023b

Asked:

on 28 Mar 2024

Commented:

on 28 Mar 2024

Community Treasure Hunt

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

Start Hunting!