Problem with addlistener to xlim

4 visualizaciones (últimos 30 días)
jvc
jvc el 27 de Jul. de 2015
Comentada: jvc el 30 de Jul. de 2015
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?

Respuesta aceptada

Tushar Sinha
Tushar Sinha el 30 de Jul. de 2015
Editada: Tushar Sinha el 30 de Jul. de 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
  1 comentario
jvc
jvc el 30 de Jul. de 2015
Tushar, Thanks for the information - I thought this behavior used to be different prior to 2014B but I was not certain. Do you know if there is some other property to which the listener could be pointed in order to assure that my callback would be triggered when the axes are updated via ylim('auto')? Thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by