How to change x-axis ticks labels in stackedplot?
Afficher commentaires plus anciens
h = stackedplot(rand(6,3));
I want to set x-axis ticks according to my own defined set i.e., instead of 1:6, I want to replace x-axisticks [1, 2,3 ,4,5,6] to ['A', 'S','T', 'AAA', 'BBB', 'ZZZ'] , by rotating it to 90 degree that is vertically insted of horizontally?
Réponse acceptée
Plus de réponses (2)
Simon Allosserie
le 6 Avr 2022
Modifié(e) : Simon Allosserie
le 6 Avr 2022
1 vote
Use xtick and xticklabels to change to the A, S, T, ... labels
I don't understand what you further mean with the rotating 90° though.
1 commentaire
ikushou
le 3 Nov 2022
No you can not use it when you use stackedplot.
that's really annoying
Paul Carchipulla-Morales
le 8 Fév 2023
1 vote
There is a quicker method that worked for me using NodeChildren in MATLAB2021b.
h = stackedplot(rand(6,3));
ax = findobj(h.NodeChildren, 'Type','Axes');
set(ax,'XTick',[1:6],'XTickLabel',{'A', 'S','T', 'AAA', 'BBB', 'ZZZ'})

2 commentaires
Aboltabol
le 27 Juin 2024
Does not work in 2023A or later.
SmokeTheDrone
le 20 Fév 2025
Setting the XTick worked for me in 2024b. Thanks Paul!
Catégories
En savoir plus sur Line Plots 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!

