Filter löschen
Filter löschen

Zoom in function make the both axis labeled wrongly

1 Ansicht (letzte 30 Tage)
MingCheng Zhang
MingCheng Zhang am 31 Jan. 2021
Kommentiert: MingCheng Zhang am 7 Feb. 2021
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

Akzeptierte Antwort

Shubham Khatri
Shubham Khatri am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Visual Exploration finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by