How to change x-axis ticks labels in stackedplot?
이전 댓글 표시
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?
채택된 답변
추가 답변 (2개)
Simon Allosserie
2022년 4월 6일
편집: Simon Allosserie
2022년 4월 6일
1 개 추천
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
ikushou
2022년 11월 3일
No you can not use it when you use stackedplot.
that's really annoying
Paul Carchipulla-Morales
2023년 2월 8일
1 개 추천
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
Aboltabol
2024년 6월 27일
Does not work in 2023A or later.
SmokeTheDrone
2025년 2월 20일
Setting the XTick worked for me in 2024b. Thanks Paul!
카테고리
도움말 센터 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

