how to use code for printing values on top of vertical bars with horizontal bars?
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I want to try horizontal bars and print the values right of the bars.
My actual code which prints the values on top of each bar is the following ....
% Find the x location of each bar
xvals = unique(cell2mat(get(findall(hb,'type','patch'),'xdata')));
xvals = mean(reshape(xvals,2,[]));
% Put the text there
text(xvals,[DataFps1 DataFps2 DataFps3 DataFps4 DataFps5], ...
{[DataFpsLabels1 DataFpsLabels2 DataFpsLabels3 DataFpsLabels4 DataFpsLabels5]},...
'Vert','bot','horiz','cen','FontName','Arial','Fontsize',8);
My problem is that unfortunately I don't understand this code, which means I cannot alter it correctly. I have this code from another question which I asked on this forum. When I use "hbar"for horizontal bars, the values which you can see on top of the bars disapper.
How the code has to be altered?
Thanks, David
0 个评论
回答(1 个)
Image Analyst
2013-2-4
They're the x and y values. In text, try adding an offset to the x values and reducing the y values by some factor, say half:
xvals+10,[DataFps1 DataFps2 DataFps3 DataFps4 DataFps5]* 0.5
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!