我正在使用errorbar函数来绘制我的模型预测的95%置信区间。我有上面和下面的位置;错误条";tick应该是。但是,当我使用errorbar函数时,这些tick不在所需的位置。请看下面,我非常感谢您提前提供的帮助!
% 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
如文档中所述,语法errorbar(x,y,neg,pos)
将neg
和pos
解释为y
下方和上方错误条的长度。所以你应该得到正确的绘图:
a = bar(data);
hold on
er = errorbar((1:14)', data, data-lower_CI, upper_CI-data, '.');
er.Color = [0 0 0];