Search code examples
matlabpdffigureepsdistortion

Distortion while saving matlab figure as a eps file


saveas(gcf,'result.pdf');

After I using above command to output my figure into a eps file, I got the following result.

figure.eps

However, the actual figure is like the following.

figure.jpg

I have tried using other commands like

saveas(gcf, 'result.eps');
print -depsc myplot.eps

or even the 'export_fig' library,but still can't get correct figure output.

Does anyone know where is the key point of this problem? Thanks.


[ Update ]

Following dpwe's comment, after zooming in the figure, the result of .eps is like this large.eps

and the original figure is like this large.jpg

Yes, it seems that they are much more similar!


Solution

  • The saveas function uses a default size for saving figures, I think it's something like 3/4 of your screen resolution. You can figure it out by looking at the number of pixels in the image (for a png anyway). If you run

    set(gcf,'Position',[a b c d]);
    saveas(gcf, 'result.eps');
    

    to resize the figure to the size that saveas will use to save it before it saves it, that might help.