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

Error in Matlab's builtin print function when exporting subplot as png #347

Closed mykappa closed 2 years ago

mykappa commented 2 years ago

Using the following code in v3.18:

figure
ax1 = subplot(2,2,1);
ax2 = subplot(2,2,2);
plot(rand(1,10))
export_fig(ax2,'test.png')

I get the following error message when i try to export a subplot:

An error occured with Matlab's builtin print function.
Try setting the figure Renderer to 'painters' or use opengl('software').

An error occured with Matlab's builtin print function.
Try setting the figure Renderer to 'painters' or use opengl('software').

export_fig error. Please ensure:
 * that the function you used (C:\Users\user\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\export_fig\export_fig.m) version 3.18 is from the expected location
 * and that you did not made a mistake in export_fig's expected input arguments

If the problem persists, then please report a new issue.

Error using alternatePrintPath
The output width and height must be > 0; try adjusting the figure's PaperPosition property.

Error in alternatePrintPath

Error in print (line 83)
pj = alternatePrintPath(pj);

Error in print2array>getPrintImage (line 329)
            print(fig, renderer, res_str, '-dtiff', tmp_nam);

Error in print2array (line 176)
            [A, alpha, err, ex] = getPrintImage(fig, res_str, renderer, tmp_nam);

Error in export_fig>getFigImage (line 1785)
        [A, tcol, alpha] = print2array(fig, magnify/options.aa_factor, renderer);

Error in export_fig (line 572)
            [A, tcol, alpha] = getFigImage(fig, magnify, renderer, options, pixelpos);

Error in export_fig_fail (line 8)
export_fig(ax2,'test.png')

Neither switching to painters nor using opengl('software') helps.

I am using MATLAB R2021a.

altmany commented 2 years ago

Fixed in v3.19