Calling linkaxes on uiaxes objects makes plot contents disappear when using uigridlayout
I wish to link the windows of a set of uiaxes. For regular axes objects, I would call the linkaxes function to link their windows together. In the following example, calling the linkaxes function for uiaxes objects makes any plots on these axes disappear:
% Generate UIFigure
ufig = uifigure;
% Apply grid layout to UIFigure
gl = uigridlayout(ufig, ‘RowHeight’, {‘1x’, ‘1x’, ‘1x’}, ‘ColumnWidth’, {‘1x’});
% Create three uiaxes objects; place them in the grid layout
ax1 = uiaxes(gl);
ax1.Layout.Row = 1;
ax2 = uiaxes(gl);
ax2.Layout.Row = 2;
ax3 = uiaxes(gl);
ax3.Layout.Row = 3;
% Create plots for each uiaxes object
x = 1:10;
plot(ax1, x, x);
plot(ax2, x, x.^2);
plot(ax3, x, x.^3);
% Attempt to link the uiaxes together
linkaxes([ax1 ax2 ax3]);
It is the last line of this code (with linkaxes) that makes the plots disappear. Otherwise, they show up as expected.
I believe the use of uigridlayout is contributing to the problem. In the following code snippet, which does not include the use of uigridlayout, linking the uiaxes objects together with linkaxes does not make the plots disappear:
% Generate UIFigure
ufig = uifigure;
% Create three uiaxes objects; place them side by side
ax1 = uiaxes(ufig, ‘Position’, [ 0 0 200 200]);
ax2 = uiaxes(ufig, ‘Position’, [200 0 200 200]);
ax3 = uiaxes(ufig, ‘Position’, [400 0 200 200]);
% Create plots for each uiaxes object
x = 1:10;
plot(ax1, x, x);
plot(ax2, x, x.^2);
plot(ax3, x, x.^3);
% Attempt to link the uiaxes together
linkaxes([ax1, ax2, ax3]);
I would appreciate any assistance that one could offer to help me understand and, if possible, correct this issue.I wish to link the windows of a set of uiaxes. For regular axes objects, I would call the linkaxes function to link their windows together. In the following example, calling the linkaxes function for uiaxes objects makes any plots on these axes disappear:
% Generate UIFigure
ufig = uifigure;
% Apply grid layout to UIFigure
gl = uigridlayout(ufig, ‘RowHeight’, {‘1x’, ‘1x’, ‘1x’}, ‘ColumnWidth’, {‘1x’});
% Create three uiaxes objects; place them in the grid layout
ax1 = uiaxes(gl);
ax1.Layout.Row = 1;
ax2 = uiaxes(gl);
ax2.Layout.Row = 2;
ax3 = uiaxes(gl);
ax3.Layout.Row = 3;
% Create plots for each uiaxes object
x = 1:10;
plot(ax1, x, x);
plot(ax2, x, x.^2);
plot(ax3, x, x.^3);
% Attempt to link the uiaxes together
linkaxes([ax1 ax2 ax3]);
It is the last line of this code (with linkaxes) that makes the plots disappear. Otherwise, they show up as expected.
I believe the use of uigridlayout is contributing to the problem. In the following code snippet, which does not include the use of uigridlayout, linking the uiaxes objects together with linkaxes does not make the plots disappear:
% Generate UIFigure
ufig = uifigure;
% Create three uiaxes objects; place them side by side
ax1 = uiaxes(ufig, ‘Position’, [ 0 0 200 200]);
ax2 = uiaxes(ufig, ‘Position’, [200 0 200 200]);
ax3 = uiaxes(ufig, ‘Position’, [400 0 200 200]);
% Create plots for each uiaxes object
x = 1:10;
plot(ax1, x, x);
plot(ax2, x, x.^2);
plot(ax3, x, x.^3);
% Attempt to link the uiaxes together
linkaxes([ax1, ax2, ax3]);
I would appreciate any assistance that one could offer to help me understand and, if possible, correct this issue. I wish to link the windows of a set of uiaxes. For regular axes objects, I would call the linkaxes function to link their windows together. In the following example, calling the linkaxes function for uiaxes objects makes any plots on these axes disappear:
% Generate UIFigure
ufig = uifigure;
% Apply grid layout to UIFigure
gl = uigridlayout(ufig, ‘RowHeight’, {‘1x’, ‘1x’, ‘1x’}, ‘ColumnWidth’, {‘1x’});
% Create three uiaxes objects; place them in the grid layout
ax1 = uiaxes(gl);
ax1.Layout.Row = 1;
ax2 = uiaxes(gl);
ax2.Layout.Row = 2;
ax3 = uiaxes(gl);
ax3.Layout.Row = 3;
% Create plots for each uiaxes object
x = 1:10;
plot(ax1, x, x);
plot(ax2, x, x.^2);
plot(ax3, x, x.^3);
% Attempt to link the uiaxes together
linkaxes([ax1 ax2 ax3]);
It is the last line of this code (with linkaxes) that makes the plots disappear. Otherwise, they show up as expected.
I believe the use of uigridlayout is contributing to the problem. In the following code snippet, which does not include the use of uigridlayout, linking the uiaxes objects together with linkaxes does not make the plots disappear:
% Generate UIFigure
ufig = uifigure;
% Create three uiaxes objects; place them side by side
ax1 = uiaxes(ufig, ‘Position’, [ 0 0 200 200]);
ax2 = uiaxes(ufig, ‘Position’, [200 0 200 200]);
ax3 = uiaxes(ufig, ‘Position’, [400 0 200 200]);
% Create plots for each uiaxes object
x = 1:10;
plot(ax1, x, x);
plot(ax2, x, x.^2);
plot(ax3, x, x.^3);
% Attempt to link the uiaxes together
linkaxes([ax1, ax2, ax3]);
I would appreciate any assistance that one could offer to help me understand and, if possible, correct this issue. uigridlayout, uiaxes, linkaxes, plot, disappear, appdesigner MATLAB Answers — New Questions