필터 지우기
필터 지우기

Size of exported pdf with given font size

조회 수: 23 (최근 30일)
Jan
Jan 2013년 5월 30일
Hi, I encountered a (hopefully) simple problem. I am exporting a figure to .pdf and I can't figure out how to scale the image before exporting. Of course I could scale the final .pdf, but then the font size isn't 12pt anymore! An important boundary condition is that I use LaTeX labels and ticks, e.g.:
xlabel('$x\ (\mathrm{m})$','Interpreter','LaTex','FontSize',12);
The final .pdf is about twice as large as I need, any tips how to make the axis resolution smaller please? Thank you!

답변 (2개)

Iain
Iain 2013년 5월 30일
When using report generator to make pdfs, I have found that changing the "Paperposition" property of the figure changes the size on my resultant pdf files.
  댓글 수: 3
Iain
Iain 2013년 5월 30일
You can force an axis to work on a specific scale using the "axis" command. You can force an axis to have a specific aspect ratio and size by controlling it's position.
I'd need to have a play to figure out anything better.
Oliver Woodford
Oliver Woodford 2013년 6월 19일
Jan: The export_fig help text states very clearly that the figure is exported as it appears on screen. So if you set the figure dimensions to the size you want it exported to you won't have any problems using export_fig.

댓글을 달려면 로그인하십시오.


José-Luis
José-Luis 2013년 5월 30일
편집: José-Luis 2013년 5월 30일
How about setting the size of the figure programatically:
h = plot(rand(10,1));
xlabel('$x\ (\mathrm{m})$','Interpreter','LaTex','FontSize',12);
options.units = 'centimeters';
options.FontMode = 'Fixed'; %This line and next are the important bit
options.FixedFontSize = 12;
options.Width = 20;
options.Height = 20;
options.format = 'pdf'; %or whatever options you'd like
options.FontName = 'arial';
options.Renderer = 'painters';
hgexport(gcf,'your_plot.pdf',options);
  댓글 수: 2
Jan
Jan 2013년 5월 30일
편집: Jan 2013년 5월 30일
Hi, thank you for the tip, I didn't know about hgexport and I'm trying what it can do now. The first thing i noticed is a bit strange, compare: Result from "saveas":
Result from "hgexport":
There seems to be something wrong, maybe the aspect ratio. It is an interesting option to export figures, but the problems mentioned in my comment to Iain's answer remain.
José-Luis
José-Luis 2013년 5월 30일
편집: José-Luis 2013년 5월 30일
The differences in the two plots might also be due to the renderer you chose.
Plotting figures in Matlab is a bit of a nightmare, if you modify one property, say the width, then other things will be changed and it will be hard to control the final output. Say you are interested in the paper size, the width of the figure and the aspect ratio. You can set these values and set the properties accordingly:
fH = figure;
h = axes;
lH = plot(1:10,1:10);
xlabel('$x\ (\mathrm{m})$','Interpreter','LaTex','FontSize',12);
%Sizes in cm
myPaperSize = [12 20];
width = 8;
widthLengthRatio = 0.5;
lowerLeft = [2 2];
set(fH,'PaperUnits','centimeters');
set(fH,'PaperPositionMode','manual');
set(fH,'PaperSize',myPaperSize);
set(fH,'Units','centimeters');
set(fH,'Position',[lowerLeft myPaperSize]);
set(h,'Units','centimeters');
set(h,'Position',[lowerLeft width width/widthLengthRatio]);
options.units = 'centimeters';
options.FontMode = 'Fixed';
options.FixedFontSize = 12;
options.format = 'pdf';
options.FontName = 'arial';
options.Renderer = 'painters';
hgexport(gcf,'your_plot.pdf',options);
To answer your comments:
  1. You can specify the width and get the height using the method above.
  2. What do you mean the axes scales to be the same? The XLim and YLim to be equal? If that is the case it is just a matter of set(). The ratio between the scale of the x's and the y's to be some value? In that case, DataAspectRatio (axes properties) would work if you don't care about the position of your axes. If you do, then you have to set your XLim, YLim, and Position manually so you have the required ratio.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by