Hi Ted:
Yes, this is a neat workaround, but it does indeed cause a problem.
You can think of the subplot function as doing two things: initial layout of the axes, and keeping the axes positioned as their size is automatically changed. For example, in your code snippet if you add:
xlabel(ax,'LABEL','FontSize',30)
You'll see that the label gets cut off. If you add this label without the reparenting, you'll see that the axes you add the label to gets its size adjusted, and all of the other axes get their position adjusted to line up. Note that there are several things you might change on an axes that would cause it to resize, xlabel is just one example. In short, subplot continues to manage the position of the axes without the reparenting, but you lose this behavior with reparenting.
As you're using 2020a, you might consider trying tiledlayout/nexttile (introduced in R2019b) in place of subplot. This works well in uifigures, and has some great new features for controlling your layout.
uif = uifigure;
uitg = uitabgroup(uif, 'Position', [0 0 uif.Position(3:4)]);
uit = uitab(uitg);
t=tiledlayout(uit,2,2);
for i = 1:4
nexttile(t);
end
Documentation links:
Best Answer