Filter löschen
Filter löschen

Size of exported pdf with given font size

23 Ansichten (letzte 30 Tage)
Jan
Jan am 30 Mai 2013
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!

Antworten (2)

Iain
Iain am 30 Mai 2013
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 Kommentare
Iain
Iain am 30 Mai 2013
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 am 19 Jun. 2013
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.

Melden Sie sich an, um zu kommentieren.


José-Luis
José-Luis am 30 Mai 2013
Bearbeitet: José-Luis am 30 Mai 2013
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 Kommentare
Jan
Jan am 30 Mai 2013
Bearbeitet: Jan am 30 Mai 2013
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 am 30 Mai 2013
Bearbeitet: José-Luis am 30 Mai 2013
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by