To get a faithful reproduction of what you see on screen, you have to use the getframe
and frame2im
commands as follows,
F = getframe(gcf);
[im,map] = frame2im(F);
if isempty(map)
imwrite(im,'figure.bmp');
else
imwrite(im,map,'figure.bmp');
end
If you use saveas
or print
, you will likely get a file with different dimensions and objects scaled differently, which could cause equations to get drawn incorrectly. The operation of getframe
ensures the file resolution reflects what you have on screen. From the documentation:
Resolution of Captured Frames
The resolution of the framed image depends on the size of the axes in pixels when getframe
is called. As the getframe
command takes a snapshot of the screen, if the axes is small in size (e.g.,because you have restricted the view to a window within the axes), getframe
captures fewer screen pixels, ...
This means there is no redrawing at a different scale (what messes up the equation).