how to update custom xticklabel after zooming

Hi, I have a figure where I have changed the xticklabels. How can I have matlab honor the custom xticklabels after I manually zoom in and out? For instance,
f = figure,
x = 1:100
y = rand(1,100)
plot(x,y)
set(gca,'xticklabel',get(gca,'xtick')/10)
The x-axis is now labeled from 1:10. If I zoom into 0:5 on the x-axis using the zoom botton, how can I have matlab honor the custom xticklabels and change to 0:5 instead of staying at 0:10?

Answers (1)

Use zoom ActionPostCallback property and have that callback change the labels.

1 Comment

Walter, thank you for the help. Unfortunately I'm still confused as to how this can be accomplished with the ActionPostCallback. I looked at the demo in the zoom documentation and tried copying what was done there and putting in a correction there but it's still not working...
h = zoom;
set(h,'ActionPostCallback',@mypostcallback);
set(h,'Enable','on');
function mypostcallback(obj,evd)
newLim = get(evd.Axes,'XLim');
msgbox(sprintf('The new X-Limits are [%.2f %.2f].',newLim));
set(gca,'xticklabel',get(gca,'xtick')/10)

Sign in to comment.

Categories

Asked:

S
S
on 12 Apr 2013

Community Treasure Hunt

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

Start Hunting!