An easy way to add the mean to boxplotGroup of Adam Danz?

조회 수: 1 (최근 30일)
Sim
Sim 2023년 12월 8일
댓글: Voss 2024년 6월 14일
Is there an easy and straightforward way to add the mean to the boxplotGroup of @Adam Danz?

채택된 답변

Voss
Voss 2023년 12월 8일
rng('default')
x = {rand(100,4), rand(20,4)*.8, rand(1000,4)+.2};
means = cellfun(@(x)mean(x,1),x,'UniformOutput',false);
h = boxplotGroup(x);
NG = numel(h.boxplotGroup);
for ii = 1:NG
N = size(x{ii},2);
xdata = get(h.boxplotGroup(NG-ii+1).Children(N:-1:1),{'XData'});
for jj = 1:N
line(xdata{jj},means{ii}(jj)*[1 1], ...
'Parent',h.boxplotGroup(NG-ii+1),'Color','g','Tag','Mean');
end
end
title('boxplotGroup(x)','FontName','FixedWidth')
  댓글 수: 4
Adam Danz
Adam Danz 2024년 6월 14일
For some reason I just saw this question today, about 6 months late.
Great answer, Voss!
Voss
Voss 2024년 6월 14일
Thanks Adam!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by