Labels inside bar plot

조회 수: 30 (최근 30일)
René Lampert
René Lampert 2022년 6월 12일
댓글: Star Strider 2022년 6월 18일
Dear all,
is it feasible to put the labels of the barh plot below inside the bars - and also the respective value ?
Thanks

채택된 답변

Star Strider
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
René Lampert
René Lampert 2022년 6월 18일
Thanks
Star Strider
Star Strider 2022년 6월 18일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by