MATLAB Answers

creating several bar charts with standard deviation

3 views (last 30 days)
AA
AA on 10 Apr 2018
Commented: VBBV on 1 Dec 2020
Hi, suppose you got x=mean1, mean2, mean3, mean4 stdx=eror1,error2,error3, error4
y=mean1, mean2, mean3, mean4 stdy=error1,error2,error3,erro4
I want to create multiple bar charts with standard deviation in such a way that the first bar chart displays x.mean1,stx.error1 and next to it y.mean1,sty.error1 and so on. In total I should get four charts with 2 bars in each chart.

  0 Comments

Sign in to comment.

Answers (2)


VBBV
VBBV on 1 Dec 2020
Edited: VBBV on 1 Dec 2020
clear
xmean = rand(1,4)*3
xstd = rand(1,4)
ymean = rand(1,4)*4
ystd = rand(1,4)*0.7
% in one figure
subplot(141)
bar([xmean(1) xstd(1); ymean(1) ystd(1)])
xticklabels({'xmean /xstd','ymean/ystd'})
subplot(142)
bar([xmean(2) xstd(2);ymean(2) ystd(2)])
xticklabels({'xmean /xstd','ymean/ystd'})
subplot(143)
bar([xmean(3) xstd(3); ymean(3) ystd(3)])
xticklabels({'xmean /xstd','ymean/ystd'})
subplot(144)
bar([xmean(4) xstd(4); ymean(4) ystd(4)])
xticklabels({'xmean /xstd','ymean/ystd'})
% seperate figure window
figure(1)
bar([xmean(1) xstd(1); ymean(1) ystd(1)])
xticklabels({'xmean /xstd','ymean/ystd'})
figure(2)
bar([xmean(2) xstd(2);ymean(2) ystd(2)])
xticklabels({'xmean /xstd','ymean/ystd'})
figure(3)
bar([xmean(3) xstd(3); ymean(3) ystd(3)])
xticklabels({'xmean /xstd','ymean/ystd'})
figure(4)
bar([xmean(4) xstd(4); ymean(4) ystd(4)])
xticklabels({'xmean /xstd','ymean/ystd'})

Community Treasure Hunt

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

Start Hunting!

Translated by