how to update custom xticklabel after zooming

3 views (last 30 days)
S
S on 12 Apr 2013
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)

Walter Roberson
Walter Roberson on 13 Apr 2013
Use zoom ActionPostCallback property and have that callback change the labels.
  1 Comment
S
S on 13 Apr 2013
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

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!