Labels inside bar plot
15 次查看(过去 30 天)
显示 更早的评论
Dear all,
is it feasible to put the labels of the barh plot below inside the bars - and also the respective value ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1029355/image.png)
Thanks
0 个评论
采纳的回答
Star Strider
2022-6-12
Try this —
v = 52 .^ 1./(4:-1:1);
barname = {'Small','Medium','Large','Extra Large'};
figure
hbh = barh(1:4,v, 'FaceAlpha',0.5);
xlim([0 60])
text(hbh.YEndPoints/2, hbh.XEndPoints, compose('%s = %.1f',[string(barname); v].'), 'Horiz','center', 'Vert','middle')
I changed the 'FaceAlpha' (transparency) value to make the labels easier to see.
.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!