Updating xticklabels after zooming in using datetick in multiple subplots
1 次查看(过去 30 天)
显示 更早的评论
Dear community, I am asking for your help. I am making a GUI, with a panel with 3 tabs and in the second tab I am ploting 5 subplots in a column, in order to display 5 signals. In the x axis I have the time vector and displayed as a date/time using datetick function. Beforehand I need to mention that the x axes of subplots are linked between them so if I zoom in into one image, I will have the same new xlimits. Speaking with images:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274103/image.png)
It is known that the function datetick does not "regenerate" the ticks after zooming in. By default (at least in my computers) 7 ticks are displayed. So if I want to zoom in e.g. the first 1/4 of the signal I get this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274104/image.png)
In 2013 was published a solution of this https://www.mathworks.com/matlabcentral/answers/95034-why-does-datetick-not-regenerate-tick-marks-on-the-axes-when-using-the-zoom-function-in-matlab. So I followed their steps and my problem was partially solved, because after zooming in one subplot, I have again 7 new ticklabels. The problem is that I just have the update of the xticklabels in the subplot where I am zooming in and after searching and trying for the whole day I can't find the solution to make the changes in all the subplots at the same time. An example is shown in the next picture, zooming on the subplot(5,1,2)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274105/image.png)
Can anyone please help me with this? I will really appreciate it
3 个评论
Adam
2020-3-2
I assume you are using linkaxes?
doc linkprop
will give you access to a whole load more properties to link, including XTick, XTickLabel, etc so this should work as a general idea, though if stackedplot solves the problem here then that is obviously neater. But linkprop is still useful to know about.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!