2

I want to put error bar in bar plot (above each bar). I tried

bincentres = -85:10:85;
nelements = [1,4,14,24,46,57,63,63,174,147,69,49,22,9,4,2,1,0];
err = sqrt(nelements);
bar(bincentres, nelements);
hold on
errorbar(bincentres,nelements, err);
hold off

Previously I was not getting errorbar because I was missing 'bincentres' in 'errorbar' in above code. Thanks to @Shai for pointing out that. But apart from error bar, now I get a line joining middle of each error bar. I want to skip that blue line.

4

2 回答 2

1

好吧,我找到了我真正想要的解决方案。在@Shai 建议的解决方案中,我添加了'bx',即我将其修改为

errorbar( bincenters, nelements, err,'bx' );

非常感谢@Shai。

于 2013-11-06T11:52:05.147 回答
1

尝试

errorbar( bincenters, nelements, err );
于 2013-11-06T11:12:19.597 回答