Why does axes interactions in a docked figure not work?

2 views (last 30 days)
I added a MWE below. My question is simple: why isn't the axes interactions working? It works until the figure is docked to the tool group.
% Create tool group
hToolGroup = matlab.ui.internal.desktop.ToolGroup('Demo');
hToolGroup.disableDataBrowser();
hToolGroup.hideViewTab();
% Import toolbox
import matlab.ui.internal.toolstrip.*
% Create tab for fun
hTabGroup = TabGroup();
hToolGroup.addTabGroup(hTabGroup);
hTab = Tab('Example tab');
hTabGroup.add(hTab);
% Open the tool group
hToolGroup.open();
% Create figure to dock
hFig = figure('Name', 'Example figure', 'NumberTitle', 'off');
hToolGroup.addFigure(hFig);
% Create axes within figure
ax = axes('Parent', hFig);
x = linspace(0,2*pi,100);
y = sin(x);
plot(ax, x, y, '.-')
% Add interactions
ax.Interactions = [zoomInteraction, panInteraction];

Answers (1)

Ayush
Ayush on 7 Sep 2023
Hi Steven,
I understand that you want to perform axes interaction such as zoom and pan specifically based on your provided code in a figure that is docked to a tool group.
I see that you are using an “internal” feature which is not the intended workflow and can cause some unintended behaviour such as this. Although, a workaround for your current workflow to enable the zoom interaction in the figure axes is to use the “zoom” function to enable the zoom mode. You can refer to the below documentation to know more about the “zoom” function:
Here is a sample reference code:
% enable zoom mode on the defined axes
zoom(ax)
Using the “zoom” function, you can zoom in and out of the axes using the scroll wheel and button tap interactions.
Hope it helps,
Regards,
Ayush Misra

Categories

Find more on Data Exploration in Help Center and File Exchange

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!