App Designer 2020a: synchronizing UIAxes

11 views (last 30 days)
Waldemar
Waldemar on 29 Oct 2020
Commented: Adam Danz on 30 Jul 2021
Hi folx,
I'm programming an viewar for physiological data. My collegues wants to change zoom on x leaving y unchanged or vice versa. They also want to have a synchronized zoom on X (time) axis. I try to implement this, but it does not work. Of course I could program everything from scratch like in previous versions of matlab (with guide) but it would be nice to do this by extending the toolbar. But I got no hints how to do this.
  2 Comments
Priyanka Rai
Priyanka Rai on 11 Nov 2020
Control Chart Interactivity was enabled starting R2019a. Using Control Chart Interactivity, you can interactively explore and edit plotted data to improve the visual display of the data or reveal additional information about the data.
Some types of interactions are available through the axes toolbar. The toolbar appears at the top-right corner of the axes when you hover over the chart area.
Other types of interactions are built into the axes and are available through gestures, such as scrolling to zoom or dragging to pan. These interactions are controlled separately from those in the axes toolbar.
To show or hide the axes toolbar, set the Visible property of the AxesToolbar object to 'on' or 'off', respectively. For example, hide the toolbar for the current axes:
ax = gca;
ax.Toolbar.Visible = 'off';
The + and - icons will allow you to zoom in/out of the axes using your mouse. The hand icon will allow you to pan the axes. If this toolbar doesn't appear, it may have been turned off. To enable it, set the Visible property of the toolbar to 'on'.
app.UIAxes.Toolbar.Visible = 'on'; % or 'off' to disable
Most types of axes include a default set of built-in interactions that correspond to specific gestures. You can replace the default set with a new set of interactions, but you cannot access or modify any of the interactions in the default set.
Waldemar
Waldemar on 29 Jul 2021
This kind of interactivity is XXXXX (censored). For data display you want to have a synchronous zoom/pan on all axes simultaneously, or just x synchronized and y separate for each channel is needed. I dunno why in designer this functionality is not available. So, yes, you have to do it almost from scratch.
I already wrote the zoom functions for app-designer, now I'm working on pan. You must use button down/up functions and scrollwheel events (I use scroll wheel of the mouse for zoom).
It is a real pain in gluteus maximus

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 30 Jul 2021
Edited: Adam Danz on 30 Jul 2021
You specified using Matlab R2020A which prevents you from using the new LimitsChangedFcn available in R2021a and onward which would simplify the solution.
The solution below deactivates panning and zooming interactivity for the y-axis and removes the pan and zoom tools from the toolbar. You can add tools as needed (see documentation). It then applies linkprop to yoke the two x-axes so that when the axis limits are changes in one axis, the other axis is updated.
% Create demo uifigure with 2 uiaxes
app.UIFigure = uifigure('Position', [500 200 700 400]);
app.UIAxes1 = uiaxes(app.UIFigure,'Position',[10 30 320 300]);
app.UIAxes2 = uiaxes(app.UIFigure,'Position',[340 30 320 300]);
% Limit toolbar to eliminate zoom and panning
tools = {'export','restoreview'};
axtoolbar(app.UIAxes1,tools);
axtoolbar(app.UIAxes2,tools);
% Deactivate zoom and panning interactions for the y-axis
zoomObj = zoomInteraction('Dimensions','x');
panObj = panInteraction('Dimensions','x');
app.UIAxes1.Interactions = [zoomObj, panObj];
app.UIAxes2.Interactions = [zoomObj, panObj];
% Plot some data, set axis limits, etc...
rng('default')
x = rand(1,100)*10-5;
y = rand(1,100)*20-10;
plot(app.UIAxes1, x, y, 'o')
plot(app.UIAxes2, x, y, 'o')
grid(app.UIAxes1, 'on')
grid(app.UIAxes2, 'on')
% Yoke the two axes' x-axis limits
app.UIAxes1.UserData.linkprop = linkprop([app.UIAxes1, app.UIAxes2], {'xlim'});
  2 Comments
Waldemar
Waldemar on 30 Jul 2021
Error using linkprop (line 33)
Functionality not supported with UIAxes. For more information, see Graphics Support in App Designer.
So it does not work in 2020A
Adam Danz
Adam Danz on 30 Jul 2021
You could replace the uiaxes with regular axes.
App designer receives lots of enhancements with each release so you should consider updating to the current release of possible.
Also try using
linkaxes([app.UIAxes1, app.UIAxes2], 'x')
instead of linkprop but I had trouble with it so that may not work either.

Sign in to comment.

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!