Skip to content

Instantly share code, notes, and snippets.

@corydolphin
Created February 25, 2013 05:30
Saving figures in MATLAB as full size, not cutoff. Gets around issue of cutting off Title, etc. Slightly slow, but it works. Damnit MATLAB graphics library.
function [ output_args ] = saveFigure( handle, fileName )
% saveFigure
% Saves figure specified by `handle` as `fileName` in fullscreen
% as to get around the stupid behavior.
screen_size = get(0, 'ScreenSize');
origSize = get(handle, 'Position'); % grab original on screen size
set(handle, 'Position', [0 0 screen_size(3) screen_size(4) ] ); %set to scren size
set(handle,'PaperPositionMode','auto') %set paper pos for printing
saveas(handle, fileName) % save figure
set(handle,'Position', origSize) %set back to original dimensions
end
@mmagician
Copy link

Finally something that works! Thanks a lot, @corydolphin!

@saurabh-kataria
Copy link

Thanks. It saves a lot of trouble.

@b-fg
Copy link

b-fg commented Feb 10, 2017

Nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment