altmany / export_fig

A MATLAB toolbox for exporting publication quality figures
BSD 3-Clause "New" or "Revised" License
1.27k stars 365 forks source link

Unexpected location of colorbar with tiledlayout in v3.43 commit #386

Closed wangshengseee closed 7 months ago

wangshengseee commented 7 months ago
Z1 = peaks;
Z2 = membrane;
tiledlayout(2,1);
nexttile
contourf(Z1)
nexttile
contourf(Z2)
cb = colorbar;
cb.Layout.Tile = 'east';
export_fig fig -rgb -nocrop -transparent -pdf;

the location of colorbar is inconsistent with the figure in MATLAB. ftest.pdf

altmany commented 7 months ago

I cannot reproduce the problem on my Win64 computer using R2022b, everything looks perfect (unlike in your ftest.pdf file). See test.pdf

Perhaps you are using a specific Matlab release or other OS where there is a problem, I don't know because you did not provide any information on your environment.

Try to add a call to drawnow before your call to export_fig, perhaps this will solve the problem.

I am closing this issue for now. If the problem is consistent and the drawnow workaround did not resolve the problem, then provide additional information about your setup environment and reopen this issue.

wangshengseee commented 7 months ago

I found that if the code is executed in live script, the problem can be reproduced. But everything is good in Script.

MATLAB R2023b Update 2 64-bit(win64)