Error Bar lines are connected in bar plot

For some reason, lines are connecting my mean values when I add error bars to a bar plot.... any idea how to fix this?
Here's my code:
sens_top = sens_top(~isnan(sens_top));
spec_top = spec_top(~isnan(spec_top));
sens_bottom = sens_bottom(~isnan(sens_bottom));
spec_bottom = spec_bottom(~isnan(spec_bottom));
data(1) = mean(sens_top);
data(2) = mean(spec_top);
data(3) = mean(sens_bottom);
data(4) = mean(spec_bottom);
errhigh(1) = prctile(sens_top, 75);
errhigh(2) = prctile(spec_top, 75);
errhigh(3) = prctile(sens_bottom, 75);
errhigh(4) = prctile(spec_bottom, 75);
errlow(1) = prctile(sens_top, 25);
errlow(2) = prctile(spec_top, 25);
errlow(3) = prctile(sens_bottom, 25);
errlow(4) = prctile(spec_bottom, 25);
x = 1:4;
figure
bar(x, data)
hold on
er = errorbar(x, data, errlow, errhigh);
er.Color = [0 0 0];
er.LineStyle = 'none';
set(gca,'xticklabel',{'Worst Feat. Sensitivity', 'Worst Feat. Specificity',...
'Best Feat. Sensitivity', 'Best Feat. Specificity'});
odd bar.PNG

Plus de réponses (0)

Catégories

En savoir plus sur Discrete Data Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by