[Matlab] Bar with errors
The snippet can be accessed without any authentication.
Authored by
Amaury Guillermin
barWithErrors.m 425 B
function barWithErrors(x, y, err, legends)
b = bar(x, y);
hold on
% Calculate the number of groups and number of bars in each group
[ngroups,nbars] = size(y);
% Get the x coordinate of the bars
xi = nan(nbars, ngroups);
for i = 1:nbars
xi(i,:) = b(i).XEndPoints;
end
errorbar(xi', y, err,'k','linestyle','none');%Adding the errorbars
hold off
legend(legends);
end
Please register or sign in to comment