Labels inside bar plot
조회 수: 19 (최근 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.
.
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!