Trouble adding error bars to bar graph

2 Ansichten (letzte 30 Tage)
Heidi Hirsh
Heidi Hirsh am 17 Mär. 2020
Kommentiert: Heidi Hirsh am 24 Mär. 2020
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 Kommentare
dpb
dpb am 17 Mär. 2020
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 am 17 Mär. 2020
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!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

dpb
dpb am 17 Mär. 2020
  9 Kommentare
dpb
dpb am 24 Mär. 2020
Rearrange your groups/x values to match the groups you want highlighted the same.
Heidi Hirsh
Heidi Hirsh am 24 Mär. 2020
I'm not sure I understand what you mean

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by