Trouble adding error bars to bar graph

2 次查看(过去 30 天)
I am trying to add error bars to bar graph. The figure looks fine if I run it without the error bars as just bar(coh). (see attached) I want to the bars to be groups as shown. I'm wondering if that grouping is messing up the error bars.
Thank you in advance for any help!
Hope you are all staying safe and healthy Matlab community.
x = 1:12;
coh = [0.9862, 0.9773
0.971, 0.9544
0.8969, 0.6791
0.8835, 0.9051
0.8558, 0.6727
0.6727, 0.8641];
errhigh = [0.0083, 0.0137
0.0137, 0.0274
0.0611, 0.1797
0.0688, 0.0563
0.1426, 0.1829
0.0875, 0.0799];
errlow = [0.0208, 0.034
0.043, 0.0661
0.1382, 0.3105
0.1533, 0.1288
0.1827, 0.3135
0.1879, 0.1743];
figure
bar(x,coh)
%bar(coh)
hold on
er = errorbar(x,coh,errlow,errhigh);
er.Color = [0 0 0];
er.LineStyle = 'none';
hold off
  3 个评论
dpb
dpb 2020-3-17
In 40 years, TMW has yet to provide any decent hatching... :(
There are some submissions on File Exchange; all that I've used have warts of various severity; and whether any will work with bar I've never tried/looked.
Heidi Hirsh
Heidi Hirsh 2020-3-17
Dang! I might hold off on that detail for now. The error bar issue is more critical at the moment. Thank you for the heads up!

请先登录,再进行评论。

采纳的回答

dpb
dpb 2020-3-17
  9 个评论
dpb
dpb 2020-3-24
Rearrange your groups/x values to match the groups you want highlighted the same.
Heidi Hirsh
Heidi Hirsh 2020-3-24
I'm not sure I understand what you mean

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by