Problem with addlistener to xlim
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a routine which needs to execute automatically every time the axis limits change in a plot. I have accomplished this by adding a listener with a callback function which updates the plot as required:
addlistener(axhdl, 'YLim', 'PostSet', @yaxisrescale)
My problem is that this solution only seems to work in HG2 (2014B, Win7) when the axis scaling is set explicitly, as in:
ylim([0,1]);% callback is properly triggered
If ylim is called with the 'auto' option the callback function is not triggered even if the axis was rescaled as a result of the call to ylim.
ylim('auto');% callback is not triggered - even if the axis is rescaled as a result of the call
Can anybody explain why this is happening and even better how to guarantee that every time the axis limits are changed my callback will be triggered?
0 Commenti
Risposta accettata
Tushar Sinha
il 30 Lug 2015
Modificato: Tushar Sinha
il 30 Lug 2015
Hi Jon,
It is my understanding that you wish to know why the callback is not triggered when the axis limits are changed using the "ylim('auto')" command in MATLAB R2014b. I also understand that you wish to know if there is a workaround to achieve this.
This behavior is as expected. When MATLAB R2014b is automatically calculating the limits, the limits frequently change several times as MATLAB inspects each member of the axes and updates the limits. Allowing listeners to be triggered during the automatic calculation (even if no listener was attached) would have caused performance degradation for all users (even if they are not using listeners), so the ability to trigger listeners with automatically calculated property value changes was disabled for performance reasons.
However, in MATLAB R2014a, the callback is triggered even when the ylim mode is set to "auto". If you have this version of MATLAB you can achieve the desired behavior. There are no workarounds as of now for MATLAB R2014b. I work for Mathworks and I have forwarded this feedback to the appropriate product team.
Thanks,
Tushar
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!