How to make a vertical label horizontal?
Afficher commentaires plus anciens
Hi, I am trying to give each bar a label. However, when I try to do it, it displays the label vertically, but I would like to have it horizontally otherwise it doesn't fit.. Does anyone know how to do that?? Thanks!!!
x = 1:1:15;
y = vMean(1:15);
name = {'gross', 'comp', 'rate', 'inv', 'gross', 'comp', 'rate', 'inv', 'gross', 'comp', 'rate', 'inv','gross', 'comp', 'rate'}
figure(6);
bar(x,y);
set(get(gca, 'XTicklabel'),'rotation', name);
1 commentaire
Réponse acceptée
Plus de réponses (2)
set(get(gca, 'XTicklabel'),'rotation', name)
Almost. But:
get(gca, 'XTicklabel')
gets the strings of the XTickLabels as cell string. Not useful here. Better:
set(gca, 'XTicklabel', name, 'XTickLabelRotation', 90)
1 commentaire
Image Analyst
le 27 Mai 2018
Or, for versions later than R2014b
ax = gca;
ax.XTickLabel = name;
ax.XTickLabelRotation = 90;
if you want the OOP way of setting properties like other languages use.
Laurel Borggreve
le 28 Mai 2018
0 votes
Catégories
En savoir plus sur Object Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!