Error bars for every other bar

3 ビュー (過去 30 日間)
Andre White
Andre White 2022 年 12 月 14 日
コメント済み: Andre White 2022 年 12 月 14 日
Hi everyone:
I am trying to set an error bar on every other bar. The error bar goes where each tick label is located. I am using the following code:
figure
x=1:4;
o_tip=[10.6,0.5300,1.3158,5.3300];
lower=[0.1900, 0.0500,0.0478, 1.3500];
upper=[ 0.1200, 0.0600, 0.0942, 1.4400];
kap=[10.0000,0.5000,3.4000,4.4000];
b=bar(x,[o_tip;kap]);
hold on
er=errorbar(x,o_tip,lower,upper);
%er.Color = [0 0 0];
er.LineStyle = 'none';
Can you please help me to solve this problem?
Thank you

採用された回答

Dave B
Dave B 2022 年 12 月 14 日
I think what you're trying to do is put the errorbars on the first bar series? You can do this using the XEndPoints from the bar, which include not only the x values but the offset that's used by bar to make the grouped bar chart:
x=1:4;
o_tip=[10.6,0.5300,1.3158,5.3300];
lower=[0.1900, 0.0500,0.0478, 1.3500];
upper=[ 0.1200, 0.0600, 0.0942, 1.4400];
kap=[10.0000,0.5000,3.4000,4.4000];
b=bar(x,[o_tip;kap]);
hold on
er=errorbar(b(1).XEndPoints,o_tip,lower,upper);
er.Color = [0 0 0];
er.LineStyle = 'none';
(If you then want to put errorbars on the second series, just use b(2) in place of b(1), to get the middle of the orange bars)
  1 件のコメント
Andre White
Andre White 2022 年 12 月 14 日
Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBar Plots についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by