'Restore View' of Axes does not notify 'PostSet' property listener
10 views (last 30 days)
Show older comments
MathWorks Support Team
on 18 May 2021
Commented: Walter Roberson
on 7 Aug 2022
When I create an axes and listener for the 'XLim' property, zooming/panning causes the listener to trigger, but pressing "Restore View" does not trigger the callback. See the example code below:
>> a = axes;
>> addlistener(a, 'XLim', 'PostSet', @(~,~) disp('XLim changed'));
Is there a workaround that also accounts for a change in axis limits caused by "Restore View"?
Accepted Answer
MathWorks Support Team
on 18 May 2021
In MATLAB R2021a, 'LimitsChangedFcn' was added as a callback for 'XAxis,' which should resolve the issue. You can see an example of this below:
ax = axes;
ax.XAxis.LimitsChangedFcn = @limitsChanged
hold(ax, 'on');
plot(ax,1:10);
function limitsCallback(~,~)
disp('limits changed');
end
1 Comment
Walter Roberson
on 7 Aug 2022
perhaps have the limit changed function broadcast an event that you have listeners for?
More Answers (0)
See Also
Categories
Find more on Visual Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!