Labels inside bar plot
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
René Lampert
le 12 Juin 2022
Commenté : Star Strider
le 18 Juin 2022
Dear all,
is it feasible to put the labels of the barh plot below inside the bars - and also the respective value ?

Thanks
0 commentaires
Réponse acceptée
Star Strider
le 12 Juin 2022
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Labels and Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
