Skip to content

Instantly share code, notes, and snippets.

@RomaKoks
Forked from corydolphin/saveFigure.m
Created October 10, 2016 11:16
Show Gist options
  • Save RomaKoks/28b8719d8ec83f4b3b768b5e89ebefb4 to your computer and use it in GitHub Desktop.
Save RomaKoks/28b8719d8ec83f4b3b768b5e89ebefb4 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment