matlab - How to save a plot into a PDF file without a large margin around -


this question has answer here:

if print plot in eps format, content of eps file occupied plot. if print plot in pdf format, there big margins above , below plot in pdf file. how can save plot in pdf file without big margin around plot?

my guess how automatically choose proper "paper" size in pdf file print to, according plot size.

this question have asked @ tex.stackexchange.com, have got replies tried solve problem outside matlab, , still don't quite understand reply tried solve within matlab. see if there more opinions here.

what mean "the proper size"? matlab figures vector graphics, can choose size want on plot.

you can set size of paper , position of figure function set.

example:

plot(epx(1:5)); set(gcf, 'paperposition', [0 0 5 5]); %position plot @ left hand corner width 5 , height 5. set(gcf, 'papersize', [5 5]); %set paper have width 5 , height 5. saveas(gcf, 'test', 'pdf') %save figure 

enter image description here

the above code remove of borders, not all. because left-hand corner ([0 0] in position vector) not "true" left-hand corner. remove more of borders, can adjust paperposition , papersize vectors.

example:

plot(exp(1:5)) set(gcf, 'paperposition', [-0.5 -0.25 6 5.5]); %position plot further left , down. extend plot fill entire paper. set(gcf, 'papersize', [5 5]); %keep same paper size saveas(gcf, 'test', 'pdf') 

enter image description here


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -