Error bars for every other bar
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Errorbars 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!