about axis ticks: how to set 10 ticks with 5 labels?

2 ビュー (過去 30 日間)
Yuji Zhang
Yuji Zhang 2013 年 11 月 23 日
コメント済み: Yuji Zhang 2013 年 11 月 23 日
Hi everyone,
I want the axis to have ticks at 1:1:10, and tick labels only at 2:2:10
Anybody know how to do this? I tried
x=1:10;
y = x;
plot(x, y)
ylim([0 10])
set(gca,'YTick', 1:1:10, 'YTickLabel', 2:2:10 );
set(gcf,'PaperUnits','inches','PaperPosition',[0 0 2 2])
print(gcf,'-dtiffn','-r600', 'test.tiff');
The result is something that doesn't make sense. See attachment please.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 23 日
編集済み: Azzi Abdelmalek 2013 年 11 月 23 日
x=1:10;
y = x;
plot(x, y)
ylim([0 10])
set(gca,'YTick', 1:1:10, 'YTickLabel', {'' '2' '' '4' '' '6' '' '8' '' '10'} );
  1 件のコメント
Yuji Zhang
Yuji Zhang 2013 年 11 月 23 日
nice nice. thanks a lot!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by