Size of exported pdf with given font size
23 ビュー (過去 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!
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
0 件のコメント
回答 (2 件)
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
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
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
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 件のコメント
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:
- You can specify the width and get the height using the method above.
- 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 Center および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!