The linkprop function is a lower-level function that creates a property-change listener that syncs corresponding properties in any specified array of object handles. Luckily, there is a very easy and simple workaround, namely to use linkprop rather than linkaxes. I wish that linkaxes used this mechanism, rather than its current ApplicationData one. This ensures that all listeners are accessible and active until their container is deleted or they are specifically modified/removed. However, unlike the linkaxes behavior, addlistener‘s listener handles are always appended to AutoListeners_‘s contents, rather than replacing it. That repeated calls to linkaxes should override (rather than complement) each other.Īs a side note, the addlistener function creates a listener and then persists it in the object’s hidden AutoListeners_ property.That Matlab listeners get deleted so easily without so much as a console warning, and certainly against naive intuition.Some people may possibly complain about both issues at this point: So when we overrode the first set of listener handles, we effectively deleted them, as if they were never set in the first place. It so happens that Matlab listeners have a very nasty feature of being deleted when they are no longer referenced anywhere (within a workspace variable or object property). But when we placed the second set of linkaxes commands, the internal field in the axes’ ApplicationData property was overriden with the new listeners (that synced the rows’ Y-limits). Therefore, when we placed the first set of linkaxes commands, the axes were correctly synced vertically (ax(1,1) with ax(2,1) in their X-limits, and similarly ax(1,2) with ax(2,2)). In either case, the field name was constant. Specifically, up to a certain Matlab release (R2013b?), the listeners were placed in a field called ‘listener_’, and since then in a field called ‘graphics_linkaxes’. The reason for this unexpected behavior is that under the hood, linkaxes attaches property-change listeners to the corresponding axes, and stores these listeners in the axes’ hidden ApplicationData property (which is typically accessible via the getappdata / setappdata / isappdata / rmappdata set of functions). The problem was that the plots didn’t behave as expected: when zooming in on the bottom-left axes, for example, only the bottom-right axes was updated (Y-limits synced), whereas the top-left axes’ X-limits remained unchanged:Īpparently, the second set of two linkaxes commands (to sync the rows’ Y-limits) overrode the first set of two linkaxes commands (to sync the columns’ X-limits). Linkaxes (ax (:, 2 ), 'x' ) % right column Linkaxes (ax (:, 1 ), 'x' ) % left column
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |