Created
July 22, 2014 14:06
-
-
Save raviramanathan/5e7b6ed0efceaa3d38fa to your computer and use it in GitHub Desktop.
Setting Paper Size in Matlab Figures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I repeatedly look for the code to specify paper size and attributes in matlab for figures. | |
Here is how to do it : | |
hFig = gcf; | |
%# centimeters units | |
X = 42.0; %# A3 paper size | |
Y = 29.7; %# A3 paper size | |
% Or | |
X = 8.0; Y = 12.0 ; % custom size | |
xMargin = 1; %# left/right margins from page borders | |
yMargin = 1; %# bottom/top margins from page borders | |
xSize = X - 2*xMargin; %# figure size on paper (widht & hieght) | |
ySize = Y - 2*yMargin; %# figure size on paper (widht & hieght) | |
%# figure size printed on paper | |
set(hFig, 'PaperUnits','centimeters') | |
set(hFig, 'PaperSize',[X Y]) | |
set(hFig, 'PaperPosition',[xMargin yMargin xSize ySize]) | |
set(hFig, 'PaperOrientation','portrait') | |
% thanks for the folks on Matlab Forums & Stackoverflow for the codet. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment