determine axis limits *before* plotting..?

조회 수: 22(최근 30일)
Bradley Stiritz
Bradley Stiritz 2012년 9월 9일
Hi everyone,
I need to determine the y-axis limits "before" rendering my plot, b/c the elements are rendered in a loop, one at a time. xlim() isn't any use in this case. Will I have to reverse-engineer MATLAB's algorithm, or is there another approach?
Thanks, Brad
  댓글 수: 3
Oleg Komarov
Oleg Komarov 2012년 9월 9일
I think we might help you if you posted the code.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan 2012년 9월 9일
편집: Jan 2012년 9월 10일
Yair has explained some tricks to You can set the XLimMode of the current axes to 'fixed' and let Matlab determine the limits at the end only by resetting it to 'auto'.
[EDITED, link fixed, thanks Yair]
  댓글 수: 3
Bradley Stiritz
Bradley Stiritz 2012년 9월 10일
Yair, thanks for the very helpful blog postings. Your work is greatly appreciated, as always!

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Image Analyst
Image Analyst 2012년 9월 9일
You can save the y and x limits for the current axes at any time by using the ylim and xlim functions:
% Save initial limits.
initial_ylim_values = ylim();
initial_xlim_values = xlim();
% Now plot something that will change the ylimits
plot(x, y); % Some y that will change the y limits.
after_ylim_values = ylim();
after_xlim_values = xlim();
  댓글 수: 2
Image Analyst
Image Analyst 2012년 9월 9일
Then you need to set "hold on" and MATLAB will "lock down" all those settings and not allow subsequent plots to change them.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by