フィルターのクリア

How to set XTickLabel with equal width between the ticks?for 1,2, 127, and 128

1 回表示 (過去 30 日間)
sohail hameed
sohail hameed 2017 年 9 月 19 日
編集済み: sohail hameed 2017 年 9 月 20 日
width between 1 and 2 is small, similarly for 127 and 128. I need equal width for 1,2,127 and 128
  2 件のコメント
Jan
Jan 2017 年 9 月 19 日
Please post how you have created this output. Then it is possible to show you how to fix the problem. Currently answering requires to guess all details and this is not efficient.
Star Strider
Star Strider 2017 年 9 月 19 日
That is not how MATLAB normally places its 'XTick' values. I suspect you are using code written by someone else that places the x-ticks at the x-coordinates of the data.
The solution is to remove (or comment-out) the set call that creates the x-tick locations you see in the plot you posted.

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

採用された回答

Tim Berk
Tim Berk 2017 年 9 月 19 日
Your graph is reproduced (with random y-values) by
x = [1 2 8:8:120 127 128];
y = rand(size(x));
figure, plot(x,y)
set(gca,'xtick',x)
Alternatively, you can plot y against the index of x:
xi = 1:19;
figure, plot(xi,y)
Now we can put the xticks at the index, but use x for the ticklabels:
set(gca,'xtick',xi,'xticklabel',x)
Not sure if this result is what you meant (or why it would be useful). Let me know if it helps.
  3 件のコメント
Walter Roberson
Walter Roberson 2017 年 9 月 19 日
The instructions starting at "Alternatively" show how to do that.
sohail hameed
sohail hameed 2017 年 9 月 20 日
編集済み: sohail hameed 2017 年 9 月 20 日
@Walter Roberson @Tim Berk Thank You very much. It worked.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by