Zoom in function make the both axis labeled wrongly
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Shubham Khatri
2021-2-2
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!