How to change x-axis ticks labels in stackedplot?
Mostra commenti meno recenti
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?
Risposta accettata
Più risposte (2)
Simon Allosserie
il 6 Apr 2022
Modificato: Simon Allosserie
il 6 Apr 2022
1 voto
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 Commento
ikushou
il 3 Nov 2022
No you can not use it when you use stackedplot.
that's really annoying
Paul Carchipulla-Morales
il 8 Feb 2023
1 voto
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 Commenti
Aboltabol
il 27 Giu 2024
Does not work in 2023A or later.
SmokeTheDrone
il 20 Feb 2025
Setting the XTick worked for me in 2024b. Thanks Paul!
Categorie
Scopri di più su Line Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

