Figure size when printing to eps

21 views (last 30 days)
Emil
Emil on 8 Aug 2013
Hi Everyone
I might be completely misunderstanding or overlooking something here, but I use the following function to easily 'postprocess' my .fig figures for publication:
function postprocess(filename,width,height,fontsize)
% Load file
[pathstr, name, ext] = fileparts(filename);
open(filename)
% Change size
set(gcf,'units','centimeters')
set(gcf, 'PaperPositionMode', 'manual');
set(gcf,'papersize',[width,height])
set(gcf,'paperposition',[0,0,width,height])
set(gcf, 'renderer', 'painters');
% Change font
set(findall(gcf,'-property','FontSize'),'FontSize',fontsize)
set(findall(gcf,'-property','FontName'),'FontName','Times New Roman')
% Export file
print('-depsc2',name)
end
Unfortunately the size output-figure does not at all match what I specify with height and width. For example:
postprocess('Testfigure.fig',12,4,10)
Produces a figure of 25.16 × 10.06 cm. I'm using Matlab 2012a on a Mac. I guess theres probably a simple explanation, but I've been googling for hours with no luck. Any help is greatly appreciated!
Thanks! Best Regards, Emil
  2 Comments
Emil
Emil on 8 Aug 2013
Oh, I think I might just have found the answer to my own question. The command set(gcf,'units','centimeters') should be set(gcf,'paperunits','centimeters') instead.
The output doesn't seem to be exactly the size that I specify, but now at least it is pretty close!
Adrian Bogen Skibelid
Adrian Bogen Skibelid on 5 Nov 2019
Hi,
I just wanted to thank u for posting this, it made my master thesis a lot prettier.

Sign in to comment.

Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!