'Restore View' of Axes does not notify 'PostSet' property listener

10 次查看(过去 30 天)
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"?

采纳的回答

MathWorks Support Team
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Visual Exploration 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by