A problem caused by 'xlim' and 'axis equal'
7 ビュー (過去 30 日間)
古いコメントを表示
Mohammad Shojaei Arani
2023 年 11 月 29 日
コメント済み: Mohammad Shojaei Arani
2023 年 11 月 29 日
Hello,
I could not figure this problem. If you run the following then you get an error message
clc;
x=linspace(0,2*pi,1000);y1=sin(x);y2=cos(x);
subplot(2,1,1)
plot(x,y1,'-k');
xlim([-inf inf]);
ylim([-inf inf]);
xlabel('x');ylabel('y1');
legend('Sin');
axis equal;
subplot(2,1,2)
plot(x,y2,'-k');
xlim([-inf inf]);
ylim([-inf inf]);
xlabel('x');ylabel('y2');
legend('Cos');
axis equal;
I do not get any error if I remove 'xlim','ylim' stuff or if, instead, I renove 'axis eqaul'. I need to keep everything. How can I solve this annoying issue?
Thanks in advance!
Babak
採用された回答
Dyuman Joshi
2023 年 11 月 29 日
移動済み: Image Analyst
2023 年 11 月 29 日
"So, how can I use xlim([-inf inf]) and axis equal at the same time?"
You can not. As I said before, atleast 1 input value to xlim/ylim must be finite.
"I want my x and y axes to be equal. "
Then provide the same limits to both axes.
"Therefpre, I do not know the limits and have to use xlim([-inf inf])."
MATLAB will adjust the limits automatically according to the given data.
3 件のコメント
Image Analyst
2023 年 11 月 29 日
To be explicit, just remove these lines entirely
xlim([-inf inf]);
ylim([-inf inf]);
and MATLAB will decide on "nice" limits to use automatically.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!