Keep the graphic's zoom

Hi,
I would like to know how I can keep the zoom of graphic when I will go to change the variable that I'm watching at the moment.
thanks
regards

6 件のコメント

Andrew Newell
Andrew Newell 2011 年 3 月 14 日
By "changing the variable", do you mean replotting with new values?
Mtlb Usr
Mtlb Usr 2011 年 3 月 14 日
Hi Andrew,
No exactly. I have got a multiple Y axis variable 2D graphic and when I want to change the current y axis I have got a popupmenu to select other variable.
When I changed the variable there isn't a new plot. Instead of this there is a axis change.
Do you understand me?
thanks
regards.
Andrew Newell
Andrew Newell 2011 年 3 月 14 日
I think so. Do you want to preserve the axes limits or the scale? (In other words, if your X axis limits are [3 5] after zooming, do you want to keep it at [3 5] or [Xlower Xlower+2]?)
Mtlb Usr
Mtlb Usr 2011 年 3 月 15 日
Hi Andrew,
OK,for now I want to preserve the axis limits after zooming and then when I changed Y axis variable to keep these limits.
regards
Mtlb Usr
Mtlb Usr 2011 年 3 月 16 日
Hi Andrew,
Finally, do you know how I can preserve the axis limits after zooming?
thanks
regards
Jan
Jan 2011 年 3 月 16 日
Please anser my question. Keeping the limits and zooming is a contradiction. Therefore you cannot do both.

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

 採用された回答

Jan
Jan 2011 年 3 月 14 日

2 投票

Another approach:
y1 = rand(1, 100);
y2 = rand(1, 200) * 2;
AxesH = axes('NextPlot', 'add');
Plot1H = plot(y1);
pause(2.0);
set(AxesH, 'XLimMode', 'manual', 'YLimMode', 'manual');
Plot2H = plot(y2, 'r');
Or you can replace the XData and YData of the plotted line directly instead of the last line:
set(Plot1H, 'XData', 1:200, 'YData', rand(1, 200));

7 件のコメント

Mtlb Usr
Mtlb Usr 2011 年 3 月 15 日
Hi Jan,
If I understand you well, you said to me that if I changed XData & YData properties respectively I would maintain the zoom after changing the variable.
Am I right?
regards
Jan
Jan 2011 年 3 月 15 日
What is "the zoom" and how can it be maintained?
The shown method fixes the X- and Y-limits.
Mtlb Usr
Mtlb Usr 2011 年 3 月 17 日
Hi Jan,
I have looked your comment.
Then, I'm interested in keeping the zoom. How can I do it?
regards
Jan
Jan 2011 年 3 月 17 日
Let me try it again: What is "keeping the zoom"? This is simply no well defined term and you have to explain it, before we can help you.
If you want to fix the axis limits, the above shown code does it already: "set(AxesH, 'XLimMode', 'manual')".
Have you tried to run the shown code? Does it solve your problem? Did problems occur? Which? Do the results differ from your expectations? If so, describe the differences.
Mtlb Usr
Mtlb Usr 2011 年 3 月 17 日
Hi Jan,
Sorry, I haven't realized.
Well, When I said keeping the zoom is that keeping the zoom that I have applied over one variable when I decide to change for other variable.
Do you understand me now?
regards
Jan
Jan 2011 年 3 月 17 日
Perhaps I understand. Did you try my code?
Mtlb Usr
Mtlb Usr 2011 年 3 月 17 日
Hi Jan,
I have could resolve the issue.
I had the answer in frot of me...
The solution has been put the keeplimits arg when I call datetick function.
Sometimes, I think that when you are thinking that you have a big problem, really it's not true because you have a very simple solution for this.
However, thank you for trying to help me.
regards

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

その他の回答 (1 件)

Andrew Newell
Andrew Newell 2011 年 3 月 14 日

0 投票

If I understand your question, you can do something like the following. Make your first plot, for example
plot(1:10)
Zoom in, and then save the values of axis:
v = axis;
Finally, make your next plot and set the axis values.
plot(3:5)
axis(v)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

2011 年 3 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by