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
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com