Issue with errorbar plotting: doesn't plot the right position/ticks
Show older comments
Hi,
I'm using the errorbar function to plot the 95% confidence interval of my model predictions. I have the upper and lower position of where the "errorbar" tick should be. When I use the errorbar function however, these ticks are not at the right position. Please see below, I highly appreciate your help in advance!
% data for errorbars
data = [-0.329764340000000;-0.374996630000000;-0.279023200000000;-0.366639140000000;0.347093700000000;0.545207860000000;0.751462400000000;-0.829505260000000;0.829507770000000;-0.545235100000000;0.524703500000000;0.232506130000000;-0.403305050000000;0.397193100000000];
%upper and lower ticks (positions) of the CI / errorbars
lower_CI = [-0.584740242855886;-0.570326581039562;-0.517823465974172;-0.629680037764874;-0.246945265039860;0.0562831850081804;0.360917757402951;-0.975194052079753;0.732974670525949;-0.698941828936124;-0.125875916733751;-0.277119510479645;-0.574489102702906;-0.115446583316303]
upper_CI = [0.147697669032193;0.0388520624922168;0.314905648112612;0.166970294864421;0.590855094796161;0.812980025737368;0.831301062393713;-0.701031711901664;0.985337808304139;-0.0585632559357397;0.700283292166636;0.563252495614094;0.166863127706487;0.708490555044120]
figure;
a = bar(data);
hold on
er = errorbar((1:14)',data,lower_CI,upper_CI, '.', 'vertical');
er.Color = [0 0 0];
hold off
Accepted Answer
More Answers (1)
Katharina Voigt
on 20 Jun 2021
0 votes
Categories
Find more on Errorbars in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!