Bar(matrix) with errorbars on the same figure

5 visualizaciones (últimos 30 días)
fu-hua yang
fu-hua yang el 30 de Dic. de 2016
Comentada: Star Strider el 3 de En. de 2017
Hi
I'm trying to plot bar with errorbars on the same figure. I tryed but it doesn't seem to work. Code: a=<4x4 double> = [0,1,0,0; 4,3,2,1; 2,2,1,3; 1,0,0,0] b=<4x4 double> = [0,1,0,0; 1,2,1,1; 1,1,1,2; 1,0,0,0] bar(a); hold on;errorbar(a,b,'.'); the answer is
How to put errorbar on each bar?

Respuestas (1)

Star Strider
Star Strider el 30 de Dic. de 2016
See Grouped Bar Series Xdata in 2014b. You can easily adapt Kelly’s code to your data.
  4 comentarios
fu-hua yang
fu-hua yang el 3 de En. de 2017
Thanks a lot!! 2014b differ 2012a but I get it now:P
Star Strider
Star Strider el 3 de En. de 2017
My pleasure!
I assumed you were using R2014b or later. I can no longer run this code (archived from a 2014 Answer), so I will let you adapt it. The loop is different for R2014a and earlier:
load('Mean.mat') % Mean contains all mean values and consists of 5 rows
load('Stddeviation.mat')
x = [time]; % define x-axis
y = [IC1,IC2,IC3,IC4]; % define y-axis
e = [sd1,sd2,sd3,sd4,sd5,sd6]'; % define standard deviation
figure
hBars = bar(y,1.0,'grouped');
set(gca,'XTickLabel',{'Baseline','0,1','0.2','0.3','0.4','0.5'})
% set ticks and tick labels
xlabel('Time')
ylabel('Impulse')
hold on
for k1 = 1:4
hb = get(get(hBars(k1),'Children'), 'XData');
midbar = mean(hb);
errorbar(midbar, y(:,k1), e(:,k1), '.') % plotting errors
end
title('Impulse');
legend('a','b','c','d','Location','SouthEastOutside')
% put in lower right
box off
hold off

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by