MATLAB Autoscaling Issue for Constant Numbers

1 回表示 (過去 30 日間)
Awais Raza
Awais Raza 2018 年 9 月 16 日
コメント済み: Walter Roberson 2018 年 9 月 19 日
I have an array of very small constant numbers (0.0025). When I plot it, the autoscaled y-axis is [-1 1.5]. This 'zoomed out' scale makes the plotted line seem to be zero. I have used axis('tight') as well but it doesn't zoom in enough either.
t=[0:5]'; y=0*t + 0.0025; figure; plot(t,y);
If this is intended autoscaling behavior, it seems to be a poor design. Is there a way to change this behavior without defining my custom axis for every plot?
Note that if my data isn't constant, i.e. t=[0:5]'; y=0*t + 0.0025; y(3) = y(3) + eps; figure; plot(t,y);
The autoscaling is acceptable.

回答 (2 件)

Naman Chaturvedi
Naman Chaturvedi 2018 年 9 月 19 日
You can use axis and xlim and ylim

Awais Raza
Awais Raza 2018 年 9 月 19 日
Yes, I understand that I can use custom axis for every plot.
Is there a reason autoscaling for a constant line is not as smart as it is for a non-constant line? For instance, the only difference between the two plots in my post is that of a single point being a tiny bit different. Yet, the autoscale on figure 1 is very non-intuitive and that for figure 2 is exactly what I would need.
Thank you for your help.
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 9 月 19 日
I agree that it appears to be a bug.

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

カテゴリ

Help Center および File ExchangeGraphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by