Thread Subject: Pan and zoom callbacks at once

Subject: Pan and zoom callbacks at once

From: Norman

Date: 24 Jun, 2009 11:08:03

Message: 1 of 1

Hi!

I have a figure with several subplots and I set the YLims, XLims and the Ticks manually. Now, if the user wants to zoom or to pan the plots (linked together via linkaxes), the axis ticks are worthless of course. That's why I wanted to use the ActionPreCallback for the pan and zoom funtion to set the tickLabelMode to 'auto' again. I encountered some weird issue, I think most of them because I never used callback until now, so I want to know what you think of my solution and what might be a better one too.

In the programm which sets up the subplots these lines are new:

p = pan(gcf);
set(p,'ActionPreCallback',@myprepancallback);
set(p,'Enable','on');
z = zoom(gcf);
set(z,'ActionPreCallback',@myprezoomcallback);
set(z,'Enable','on');

In @myprepancallback and @myprezoomcallback the setting of the TickLabelMode is done, something like

function myprepancallback(obj,evd)
  children = get(gcf,'Children') % 1st children is not subplot, so use 2nd
  set(children(2),'XTickMode','auto');
  set(children(2),'YTickMode','auto');
  set(children(2),'XTickLabelMode','auto');
  set(children(2),'YTickLabelMode','auto');
end

I noticed that the 'set(p,'Enable','on')' adds on children of gcf, but 'set(z,'Enable','on')' removes that object again, why (and zoom is done, so there seems to be no need for a new children) ?

Any comments on this?

Greetings,
Norman

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com