Dear all,
is it feasible to put the labels of the barh plot below inside the bars - and also the respective value ?
Thanks

 Réponse acceptée

Star Strider
Star Strider le 12 Juin 2022

0 votes

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 commentaires

René Lampert
René Lampert le 18 Juin 2022
Thanks
Star Strider
Star Strider le 18 Juin 2022
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Labels and Annotations dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by