how can I place my error bar in separate bar center?
Show older comments

load SIwb ( % load the workbook of data)
whos LTST PhA_SD BSIR SIR (% find variable)
G = findgroups(LTST, PhA_SD);(% Grouping the variables)
BSIRm=splitapply(@nanmean,BSIR,G);(% Mean of each group of BSIR)
SIRm=splitapply(@nanmean,SIR,G);(% Mean of each group of SIR)
SIRc=[BSIRm,SIRm];(% Combine the SIR mean of Baseline and after SD)
(%Calculate the standard error,SEMM function is uploaded)
BLSIRe=splitapply(@SEMM,BSIR,G);
SIRe=splitapply(@SEMM,SIR,G);
(%combine the std error of BLSIR and SIR)
SIRec=[BLSIRe, SIRe];
(%split the std error into LT and ST)
LTSIRe=SIRec(1:4,:);
STSIRe=SIRec(5:8,:);
(%split the LT and ST)
LTSIR=SIRc(1:4,:);
STSIR=SIRc(5:8,:);
(%Plot the LT graph)
subplot(2,2,1)
(%Plot the data of SI for Long term)
H=bar(LTSIR);
hold on
errorbar(LTSIR,LTSIRe,'.')
%--------------------
legend('Baseline-SIR','SIR','Location','northwest');
grid on
P=gca();
set(P,'XTICKLABEL',{'CH-PhA-','CH-PhA+','SD-PhA-','SD-PhA+'});
ylabel(P,'SIR(%)');
title('LT stress and PhA impact on SIR','FontSize',10)
(%Set up color of each group of bar)
set(H(1),'FaceColor','k');
set(H(2),'FaceColor','r');
The work book data is in attachment.
Accepted Answer
More Answers (2)
Categories
Find more on Discrete Data Plots 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!
