How to add errorbars
Show older comments
Dear all,
I want to add the errorbar for each bar, but it didn't work out.
The code I wrote is below
Can anyone fix it ? Thanks!
figure;
TGmatch=7.15;
AGmatch=8.32;
TGnonmatch=7.56;
AGnonmatch=7.84;
adRT=[TGnonmatch AGnonmatch;TGmatch AGmatch];
h=bar(adRT);
set(get(gca, 'YLabel'),'String','accuracy-adjusted RT (ms/%)','FontSize',14);
set(gca, 'FontSize',14,'XTick',[1 2],'XTickLabel',{'Nonmatch','Match' })
set(get(gca, 'Title'),'String','(C) visual-spatial attention','FontSize',16);
ylim([0 10]);
set(gca,'YTick',1:2:10);
TGmatchSE=.25;
AGmatchSE=.44;
TGnonmatchSE=.29;
AGnonmatchSE=.41;
errorbar(1,TGmatch,TGmatchSE,'k');
errorbar(1,AGmatch,AGmatchSE,'k');
errorbar(2,TGnonmatch,TGnonmatchSE,'k');
errorbar(2,AGnonmatch,AGnonmatchSE,'k');
set(gca, 'Box', 'off');
set(gca,'color','none');
legend('TG','AG','Fontsize',14);
Accepted Answer
More Answers (0)
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!