|
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
|