Ok, so far I have come up with this:
- Get the PlotBoxAspectRatio and InnerPosition properties of the axes which sizes you actually want
- Set the Parent properties of the axes which you want to change to be something that allows you to control position, like their respective figures
- Set the PlotBoxAspectRatio and InnerPosition properties of the axes to be changed to the ones you previously got and want
mwe:
x = linspace(0,5,40);
y = x.^2;
yy = y.^3;
fig1 = figure;
layout = tiledlayout(1,5);
layout.TileSpacing = 'tight';
ax1 = nexttile([1 1]);
boxplot(y)
grid on
ylabel('$y_i$ [g/l]', 'Interpreter', 'latex')
xlabel('$t$ [d]', 'Interpreter', 'latex')
ax2 = nexttile([1 4]);
plot(x,y)
grid on
ylabel('$y_i$ [g/l]', 'Interpreter', 'latex')
xlabel('$t$ [d]', 'Interpreter', 'latex')
fig2 = figure;
layout = tiledlayout(1,5);
layout.TileSpacing = 'tight';
ax3 = nexttile([1 1]);
boxplot(yy)
grid on
ylabel('$yy_i$ [g/l]', 'Interpreter', 'latex')
xlabel('$t$ [d]', 'Interpreter', 'latex')
ax4 = nexttile([1 4]);
plot(x,yy)
grid on
ylabel('$yy_i$ [g/l]', 'Interpreter', 'latex')
xlabel('$t$ [d]', 'Interpreter', 'latex')
% Change Parent property to allow change of position
ax1.Parent = fig1; ax2.Parent = fig1;
% Get and set PlotBoxAspectRatio and InnerPosition properties to desired ones
ax1.PlotBoxAspectRatio = ax3.PlotBoxAspectRatio;
ax1.InnerPosition = ax3.InnerPosition;
ax2.PlotBoxAspectRatio = ax4.PlotBoxAspectRatio;
ax2.InnerPosition = ax4.InnerPosition;
This results in identical axes with different data and ylim:
Happy to read simpler solutions!