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

2 visualizaciones (últimos 30 días)
Sim
Sim el 8 de Dic. de 2023
Comentada: Voss el 14 de Jun. de 2024
Is there an easy and straightforward way to add the mean to the boxplotGroup of @Adam Danz?

Respuesta aceptada

Voss
Voss el 8 de Dic. de 2023
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 comentarios
Adam Danz
Adam Danz el 14 de Jun. de 2024
For some reason I just saw this question today, about 6 months late.
Great answer, Voss!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by