Zoom in function make the both axis labeled wrongly

1 view (last 30 days)
Hi,
I have some problem with the "zoom in" function in figure. Initially the figure is pop-up, the x and y axis are labelled correctly, from 0 to xlim/ylim. However, when I use the zoom in function, I reaslied that the both axis are wrong, i.e. there are two zeros on x-axis. I have uploaded the pictures as attached references. Please help me on the problem. The MATLAB version is R2019b.
Thank you for any help,
Yours sincerely,
MingCheng

Accepted Answer

Shubham Khatri
Shubham Khatri on 2 Feb 2021
Hello,
You are manually setting the tick labels. When you zoom these will no longer get auto updated so you will likely end up with a mess as these tick labels get applied to totally different ticks after the zooming.
Manually setting tick labels does not go well with zooming. You'd have to add your own post-zoom callback to recalculate the tick labels for the new ticks I would think.
Take a look at
doc zoom
In particular the section on Zoom mode callbacks and the use of the zoom mode object. You can do some useful things with this object, including two that are of interest:
ActionPreCallback
ActionPostCallback
Setting these allows you to define behaviour that happens before and after the actual zooming.
You may want to set the XTickLabelMode to auto in the pre callback and then insert the code you have above that over-rides labels into the ActionPostCallback in order to have them corrected each time you zoom.
Hope it helps.

More Answers (0)

Categories

Find more on Data Exploration in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!