Extracting from boxchart function the median, quartiles, and whisker data.

Hello dear community. I've got mutliple comparisons that I have plotted with boxchart. When I hover the cursor over any boxoplot, I can see the median, quartile, and whisker info. But I'm having difficulty extracting from the boxchart properities the numerical values. My goal is to the save directly these data value that boxchart clearly produce into an array.
Here's some mock code for three boxplots :
y1 = rand(10,1);
y2 = rand(8,1);
y3 =rand(12,1);
X = [ones(length(y1),1); 2*ones(length(y2),1); 3*ones(length(y3),1)]; % boxchart positions for raw data
Y = [y1; y2; y3]; % raw data values
b = boxchart(X,Y);
If I where to type "b.DataTipTemplate.DataTipRows.Value" I can see the variables Whiskers and Medians and others but cannot access them with dot notation. How would I get the values for say the second box plot?
b.DataTipTemplate.DataTipRows.Value
ans = 'Position'
ans = 'Num Points'
ans = 'Num Outliers'
ans = 'Median'
ans = 'Quartiles'
ans = 'Whiskers'
ans = 'Outlier Value'
Thanks in advance.

 채택된 답변

Matt J
Matt J 2023년 5월 30일
편집: Matt J 2023년 5월 30일

1 개 추천

I don't believe those quantitites are directly available as permanent property data. When you position the cursor over one of the boxes, a GUI callback function is invoked to calculate them on the fly from the XData, YData property values. You can, of course, write your own function to do so as well.

댓글 수: 3

Hi Matt. First thanks for writring. That's what I suspected but wasn't sure if I was missing something. That they list the Value names though makes me doubt this. Kinda silly they don't allow the dot-indexing to extract thost values directly from the boxchart run.
Thanks again. :)
Matt J
Matt J 2023년 5월 30일
편집: Matt J 2023년 5월 30일
The real issue to me is that they call it a "Value" property when that's not what it is:
Agree. It was misleading in suggesting dot-indexed calling functionality. Thank you again for your time in writing.

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

추가 답변 (2개)

the cyclist
the cyclist 2023년 5월 30일

1 개 추천

As you may know, but just in case you do not, there is also the boxplot function, which has more flexibility than boxchart.

댓글 수: 1

Thanks. I am reverting back to boxplot; initially had liked the features in boxchart.

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

hxen
hxen 2023년 5월 30일

0 개 추천

Thank you all for the help. Much appreciated.

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

질문:

2023년 5월 29일

답변:

2023년 5월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by