Bar Plot Error Bars in 2015a

1 visualización (últimos 30 días)
Adam Braegelman
Adam Braegelman el 24 de Jun. de 2015
Comentada: Mike Garrity el 24 de Jun. de 2015
I am trying to plot a bar graph of mean and standard deviation data for an assay with 8 conditions. I can't plot the error bars using the errorbar function. The script (below) works in 2014a. How can I modify the code to work in 2015a?
figure
hold on
bar(Inv_Freq_Mean)
errorbar(1:8,Inv_Freq_Mean, Inv_Freq_Std)
  1 comentario
Mike Garrity
Mike Garrity el 24 de Jun. de 2015
That certainly looks like it should work in 2015a. Can you tell me more about what's not working? Is there an error message? Does something draw incorrectly?

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 24 de Jun. de 2015
This is one way:
[data,ctrs] = hist(randn(50,2), 10);
figure(1)
hBar = bar(ctrs, data);
ctr1 = bsxfun(@plus, hBar(1).XData, [hBar(1).XOffset]');
ctr2 = bsxfun(@plus, hBar(2).XData, [hBar(2).XOffset]');
ydt1 = hBar(1).YData;
ydt2 = hBar(2).YData;
hold on
errorbar(ctr1, ydt1, ones(size(ydt1))*0.4, '.r')
hold off
Credit goes to Kelly Kearney for discovering it.

Categorías

Más información sobre Errorbars 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