Effacer les filtres
Effacer les filtres

xlim add listener 'auto' does not work

2 vues (au cours des 30 derniers jours)
Daniel Lemus
Daniel Lemus le 7 Mai 2020
Modifié(e) : Adam Danz le 15 Avr 2021
Hi
I am using 2019b and have not been able to successfully use an evenlistener on the XLim of my axes. I want to listen to changes on the size of the axes but it seems it does not work when the XLimMode = 'auto' altough there is a clear change in XLim. Looking abit more on the issue I found a workaround (https://nl.mathworks.com/matlabcentral/answers/369377-xlim-listener-for-zoom-reset-and-linkaxes-strange-behavior) which I presume does not work anymore in this release.
addlistener(parent_ax,'XLim','PostSet',@ReposFootPrint); % This only works when XLimMode = 'manual'
This alternative using a manual property does not work given that the propety is not SetObservable
addlistener(struct(parent_ax).XAxis,'Limits','PostSet' ,@ReposFootPrint);
Any ideas on how can I use the listener in 'auto' mode?
Thank you
  4 commentaires
Daniel Lemus
Daniel Lemus le 7 Mai 2020
Modifié(e) : Daniel Lemus le 7 Mai 2020
Fig 1. Original Placement of footprint @(1,1)
Fig 2. After ploting a new line
plot(parent_ax,[0 2],[0 2])
the listener was not triggered
Fig 3. The callback ReposFootPrint is triggered once the XLim property is manually set, placing back the footprint to its original location (this should be automatic)
Adam Danz
Adam Danz le 15 Avr 2021
Modifié(e) : Adam Danz le 15 Avr 2021
In Matlab r2021a and later, see this community highlight for a demonstration of the new LimitsChangedFcn that is easier to use and more reliable than applying a listener to the xlim property. The demo moves a text object any time the axis limits change. That can easily be applied to your footprints.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Labels and Annotations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by