Trouble adding error bars to bar graph

조회 수: 2 (최근 30일)
Heidi Hirsh
Heidi Hirsh 2020년 3월 17일
댓글: Heidi Hirsh 2020년 3월 24일
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