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 don't understand your question. Can't you use xlim after the loop?
Bradley Stiritz
Bradley Stiritz 2012 年 9 月 9 日
Hi Oleg,
Thanks for your question. Let me clarify: within the rendering loop, MATLAB is forced to reset the y-axis limits & re-render the whole plot each time a new figure element is drawn which exceeds the current limits. Doing this hundreds of times for a single plot is significantly time-consuming.
Therefore, as I said, I want to determine & set the y-axis limits via ylim() "before" the rendering loop. Does this make sense?
Thanks, Brad
Oleg Komarov
Oleg Komarov 2012 年 9 月 9 日
I think we might help you if you posted the code.

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

 採用された回答

Jan
Jan 2012 年 9 月 9 日
編集済み: Jan 2012 年 9 月 10 日

0 投票

Yair has explained some tricks to http://undocumentedmatlab.com/blog/plot-performance/. 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 月 9 日
Jan, thanks, I this this might work for me. I'll test out & report back here.
Yair Altman
Yair Altman 2012 年 9 月 10 日
編集済み: Yair Altman 2012 年 9 月 10 日
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 日

0 投票

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 件のコメント

Bradley Stiritz
Bradley Stiritz 2012 年 9 月 9 日
Hi, thanks for your comment. I'm not sure you're seeing my situation? Please see my response to Oleg, above..
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.

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by