Separate tools setting callbacks for one event
이전 댓글 표시
Consider two tools that add annotations to a plot. Both toolA and toolB add annotations that are sensitive to the current YLim of the axis. toolA and toolB are completely independent. Either one or both may be used on any given plot.
Both tools add annotations that must be placed relative to one another within their set. For example, a series of labels that "stair step" down as the x-axis increases. So the position of any individual label has some dependence on the "previous" label (text object).
I have found that just adding a listener on YLim PostSet is insufficient, as the "Restore View" for zoom does not stimulate that callback. I have found I also need the same callback(s) invoked if the figure size is changed. I am aware of the LimitsChanged callback for axis objects and the SizeChanged callback for the figure objects, but as far as I can tell they can only point to a single callback function, not a list of functions.
I have figured out some rather hacky ways to handle this use case, but I'm wondering if there is a preferred method for doing something like this. It seems that addlistener would be the preferred way as that doesn't overwrite a property, but I've been unable to find a way to get that to reliably work for all use cases (like zooming and figure resizing).
[Note that I am currently using R2022b, but there are others in our group that currently need to use MATLAB as old as R2018b. We have a number of mission-critical tools that need to be recertified if the version of MATLAB changes, so there can be lags adopting the lastest version of MATLAB.]
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!