Increase gap between XTick and XTickLabel

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.

1 件のコメント

Daniel Wallace
Daniel Wallace 2017 年 5 月 24 日
編集済み: Daniel Wallace 2017 年 5 月 24 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

質問済み:

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