How to set a certain ratio for x-y axis?

As in the image, the difference each step for y-axis is 0.2, for x-axis is 1. I want to keep x-axis as 1, but change y-axis to 0.5 for each step and keep the width of the picure unchanged. So I shrink this picture vertically 2.5 times.
Is there a general method to do this? I appreciate your answer!

回答 (2 件)

Mischa Kim
Mischa Kim 2014 年 2 月 28 日
編集済み: Mischa Kim 2014 年 2 月 28 日

0 投票

Toby, I believe you want to change the ticks, correct? Use
set(gca,'YTick',-1:0.5:1)
after the plot command.

2 件のコメント

Iain
Iain 2014 年 2 月 28 日
You might want to change the axis settings.
ylim([-2.5 2.5])
that ought to do it too.
you might want to change the whole axis settings to line things up a bit better:
axis([-pi pi -2.5 2.5]) % change the values to suit.
toby
toby 2014 年 3 月 2 日
Thanks for your reply. What I want is actually changing the ratio of the figure. I want to keep x-axis -4:1:4 but make y-axis -1:0.5:1. I tried axis([]), it does not work.

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

Image Analyst
Image Analyst 2014 年 3 月 2 日

0 投票

Try using set() to adjust the 'Position' property to stretch the width and height of the graph to whatever you want
set(gca, 'Units', 'normalized', 'Position', [0,0,.5, .2]);

カテゴリ

ヘルプ センター および File ExchangeGraphics Object Properties についてさらに検索

タグ

質問済み:

2014 年 2 月 28 日

回答済み:

2014 年 3 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by