![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1823692/image.png)
regionZoomInteraction only works the first time, bug?
6 次查看(过去 30 天)
显示 更早的评论
So I noticed this very weird thing which I think is a bug...
When the switch is on by default, the regionZoom works as intended. Then I turn it off, and rotate and zoom starts to work. And turn it on again, now the regionZoom cursor shows, you can select the area, but it doesn't actually zoom.
It looks like regionZoom only works in the first instance. Second time onwards it doesn't work. ZoomInteraction still works and this issue only applies to regionZoom.
Any thoughts? Can I add regionZoom as a standard option in the axes toolbar? That would do the job too.
function ButtonPushed(app, event)
ax=app.UIAxes;
if app.Switch.Value == "Off"
ax.Interactions = [rotateInteraction zoomInteraction];
else
ax.Interactions = [regionZoomInteraction zoomInteraction] ;
end
0 个评论
回答(1 个)
Rahul
2025-1-20,6:02
I understand that you require to change interactions while using a Switch component and Button callback in your App.
After creating a dummy app, according to the description given by you, I was able to understand the reason behind the behaviour.
According to the Limitations mentioned in the documentation of 'regionZoomInteraction', the interaction is not supported for charts in a 3-D view. Hence when the Switch component is turned 'off' and the 'rotateInteraction' is used, while rotating the axis, the plot shifts to a 3-D view. Hence when the Switch component is turned 'on' again the 'regionZoomInteraction' does not function as expected.
A possible workaround for this can be to restore to the 'Default View' of the axis by clicking the 'Home' or 'Rotate 3D' icon of the plot as shown below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1823692/image.png)
This will restore the axis to a 2D view and then the 'regionZoomInteraction' will work as expected.
Refer to the following MathWorks documentation to know more:
'regionZoomInteraction': https://www.mathworks.com/help/releases/R2022a/matlab/ref/matlab.graphics.interaction.interactions.regionzoominteraction.html
Thanks.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Create Custom UI Components 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!