Hi, I'm plotting a graph that has 262 measured points. I have a 262x1 text cell array called 'txt' which contains the data I want to label for the X labels. I have started out with this code to place the corresponding x labels with each measured point.
set(gca, 'XTick',1:262, 'XTickLabel',txt(:,1))
But if I use this code all the x labels are all muddled up and you cant read the text.
I have tried:
set(gca, 'XTick',1:30:262, 'XTickLabel',txt(:,1))
But each x label doesn't line up with the corresponding measured point. How can I label the x labels but have a gap around 30 measured points between each x label, but also ensuring the measured points line up with the corresponding x label? Thanks.

 채택된 답변

dpb
dpb 2017년 5월 24일

1 개 추천

Tick labels are a 1:1 correspondence with the tick in sequence; the labels don't know about location; only ordinal number. Use
set(gca, 'XTick',1:20:262, 'XTickLabel',txt(1:20:262,1))
IOW, ensure use the labels that are in synch with the ticks.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

제품

질문:

2017년 5월 24일

편집:

2017년 5월 24일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by