bars with mean and std on them
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
talayeh ghodsi
am 9 Dez. 2020
Bearbeitet: Timo Dietz
am 10 Dez. 2020
hi every body. i need to plot bar of 2 groups in x axis each containing 3 type of datas with mean and std on them. but i have error in the following code. could anybody help me please?
Y=[32.1 21.3 53.4;10.4 9.1 23.5]; %% mean values
X = categorical({'whole V','Proposed method'});
X = reordercats(X,{'whole V','Proposed method'});
Xv = 1:numel(X);
STD_low=[0.73 0.217 0.529;0.161 0.112 0.131]; %% standard deviations
STD_high=STD_low;
figure
b=bar(Xv,Y);
xtips1 = b(1).XEndPoints;
ytips1 = b(1).YEndPoints;
for k1 = 1:size(Y,2)
ctr(k1,:) = bsxfun(@plus, b(k1).XData, b(k1).XOffset');
ydt(k1,:) = b(k1).YData;
end
hold on
heb = errorbar(ctr, ydt, STD_low.', STD_high.', '.k');
for k = 1:numel(heb)
heb(k).MarkerSize = 1;
end
labels1 = string(b(1).YData);
text(xtips1,ytips1,labels1,'HorizontalAlignment','right',...
'VerticalAlignment','bottom')
xtips2 = b(2).XEndPoints;
ytips2 = b(2).YEndPoints;
labels2 = string(b(2).YData);
text(xtips2,ytips2,labels2,'HorizontalAlignment','right',...
'VerticalAlignment','bottom')
xticklabels(X)
legend('MAD', 'HD','DSC');
xlabel('Method of best match slice achievement')
ylabel('Mean&Standard deviation (mm)')
0 Kommentare
Akzeptierte Antwort
Timo Dietz
am 10 Dez. 2020
Bearbeitet: Timo Dietz
am 10 Dez. 2020
replace the XEndPoints/YEndPoints by XData(end)/YData(end):
xtips1 = b(1).XData(end);
ytips1 = b(1).YData(end);
Btw, xticklabels(X) won't work. Either set xticklabels('auto') or xticklabels(b(1).XData)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!