Return to previous zoom level/location

9 views (last 30 days)
Anon
Anon on 25 Mar 2011
Commented: Gary on 22 Dec 2015
Let's say I have created a figure using imagesc
imagesc(X(1,:),Y(:,1),I)
and I have then used the manual zoom tool to look at a particular region in the plot. I then do some changes to I (e.g. I2 = imdilate(I,ones(3))) and plot it again, say
imagesc(X(1,:),Y(:,1),I2)
and I want to zoom at the same extent again. What would be best practice to do so?
So far I tried to employ the Xlim and Ylim axis properties, such that
imagesc(X(1,:),Y(:,1),I); % zoom in somewhere manually
b = get(gca,'Xlim');
c = get(gca,'Ylim');
and then
imagesc(X(1,:),Y(:,1),I2)
set(gca,'Xlim',b,'Ylim',c)
but this won't allow me to zoom out afterwards.

Accepted Answer

Matt Fig
Matt Fig on 25 Mar 2011
Here is an example.
load clown
image(X)% Now zoom in on the eye.
% After zooming in, do this:
.
.
L = get(gca,{'xlim','ylim'}); % Get axes limits.
X = ind2rgb(X,map);
image(X)
zoom reset
set(gca,{'xlim','ylim'},L)
% Now the plot should be zoomed in around the eye again, but you can also zoom out.
  2 Comments
Gary
Gary on 22 Dec 2015
What's the difference between what Anon did and what Matt Fig did?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!