How do I plot values on top of bar?
Show older comments
the following is my code. I want to put values on top of the bars but I could not solve the problem. I have gone through the previous but could not figure out the exact positioning.
x = [20 40 60 80 100];
y = [0.0036 0.0149;0.0033 0.0149;0.0023 0.0192;0.0021 0.0235;0.0018 0.0279];
bar(x,y)
a = (1:size(y,1)).';
x_check = [a-0.25 a+0.25];
for k=1:size(y,1)
for m = 1:size(y,2)
text(x_check(k,m),y(k,m),num2str(y(k,m),'%0.2f'),...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom')
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Objects 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!