There is an error in the subplot function in 2025a version

Carlos M. Velez S. on 2 Jun 2025 (Edited on 4 Jun 2025)
Latest activity Reply by Adam Danz on 3 Jun 2025

The following lines were added to the subplot function in version 2025a (line 291):
if ancestorFigure.Units == "normalized"
waitfor(ancestorFigure,'FigureViewReady',true);
end
That code isn't in version 2024a.
Because of this, I'm experiencing issues that cause the code to stop running when using subplot in this way:
figure('Units','normalized','Position',[0 0 0.3 0.3])
subplot(1,2,1)
...
Has anyone else encountered this error?
Does anyone understand the need for those lines of code?
Carlos M. Velez S.
Carlos M. Velez S. on 2 Jun 2025
Run this code in a MLX file:
t = 0:0.1:10; y = sin(t);
figure('Units','normalized','Position',[0 0 0.3 0.3])
subplot(1,2,1)
plot(t,y)
subplot(1,2,2)
plot(y,t)
Adam Danz
Adam Danz on 3 Jun 2025
I am able to reproduce the indefinite wait. Thanks for reporting this issue.
One workaround is to set the figure's units and position after plotting.
t = 0:0.1:10; y = sin(t);
fig = figure;
subplot(1,2,1)
plot(t,y)
subplot(1,2,2)
plot(y,t)
set(fig,'Units','normalized','Position',[0 0 0.3 0.3])
Adam Danz
Adam Danz on 2 Jun 2025
I just ran those two lines in R2025a and did not experience any issues.
figure('Units','normalized','Position',[0 0 0.3 0.3])
subplot(1,2,1)
If you just call the first line, does the figure appear?
Steve Eddins
Steve Eddins on 3 Jun 2025
@Adam Danz, I can reproduce a hang condition using the reproduction instructions that Carlos posted in his reply. It pauses and waits indefinitely on line 3 below. Ctrl-C works to return to the prompt.