How to begin axis from another value and make it a 0 point in plot matlab?

208 ビュー (過去 30 日間)
Magda
Magda 2018 年 3 月 5 日
コメント済み: Magda 2018 年 3 月 5 日
Hi,
I have some measurements. On the x label they starts from 0 to 100, but from 23 I can see something change on the plot, so I want to show a plot from 23 to 100, and that is how i do this:
plot(x,y)
axis(23, 100, 0, 40)
let's say that y is from 0 to 40 and i don't want to change it.
But now I want to make 23 a 0, so then the 100 whould be 77- how can I make this?
Thanks

採用された回答

Benjamin Kraus
Benjamin Kraus 2018 年 3 月 5 日
If you want the ticks on your plot to show something other than the real numbers, you can either (a) change the numbers, or (b) manually specify your tick values.
To demonstrate, let me create some fake data:
x = 0:100;
fakedata = x/10;
fakedata(24:end) = sin(fakedata(24:end)-2.3)+2.3;
plot(x, fakedata)
Your two options are to either: change the X-values to something different (recommended):
plot(x-23, fakedata)
xlim([0 77])
Or manually specify your tick values:
plot(x,fakedata)
xlim([23 100]);
xticks(23:10:100);
xticklabels(0:10:77);

その他の回答 (3 件)

Jos (10584)
Jos (10584) 2018 年 3 月 5 日
1) change the limits
plot(x,y)
xlim([23 100])
2) change the data (not recommended)
plot(x,y-23)

KSSV
KSSV 2018 年 3 月 5 日
xlim([23 100])
Read about xlim and ylim

Magda
Magda 2018 年 3 月 5 日
Thank You for Your response, but i meant something else
For example I made my axis from 2 to 10 because only on this range I have sth interesting, and the same plot I want to have in the range from 0 to 8 (I want cheat a little bit my measurements that the beginning of measure is somewhere else) In this example it would looks like this:
The first one is with Your recommendetion (xlim), and the second one is what I want

カテゴリ

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