Problems with making graphics figures to include in documents
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
My need: Matlab to create figures for including in articles I'm writing. I use LaTeX with PdfTeX. So I prefer Matlab to convert directly to a file mypic.pdf, say (though .eps is OK). Then \includegraphics[options]{mypic.pdf} does the job. The options include scaling, e.g. [width=.6\textwidth] so I want my figures to be created at a standard size (A5 landscape, or 6in by 4in, would both suit me).
HOWEVER Matlab figures do NOT (a) appear on screen at actual size as "print"ed, or (b) look identical to how they are "print"ed.
I'm using a MacBook Pro at 14400 by 900 resolution, pixel = 1/72 inch. Checking the properties of "root", I see Matlab has this correct.
I observe
(1) Font sizes on screen differ from printed ones.
(2) Matlab does not display the figure at the advertised dimensions.
(3) The "print"ed file does not have a tight bounding box, at least when saved as .eps. That is, it has an invisible white border that really screws up the \includegraphics process.
I ran Matlab Help's "Save Figure at Specific Size and Resolution/Preserve Axis Limits and Tick Values" example:
bar([1 10 7 8 2 2 9 3 6])
ax = gca;
ax.XTickMode = 'manual';
ax.YTickMode = 'manual';
ax.ZTickMode = 'manual';
fig = gcf;
fig.PaperUnits = 'inches';
fig.PaperPosition = [0 0 6 3];
fig.PaperPositionMode = 'manual';
print('SameAxisLimits','-dpng','-r0')
What appears on screen is nothing like what the PNG file shows when opened in the Mac's Preview app.
- PNG: correct size 6in by 3in.
- Matlab: about 5in by 4in, with much smaller font size.
To make the screen figure look similar (in geometry sense) to the PNG I have to squash it to about 4in by 2.7in, that is about 2/3rds the actual size.
My challenge to you:
- Modify the above code so the screen figure is actual size, with identical font sizes to the "print"ed version.
- Explain how I can automatically get a tight bounding box. Most graphics want that because they are created to be placed by software within a larger document. The days of printing from graphics file directly to paper are long gone.
BTW for .eps the -loose option as in
print -depsc -loose -r0 SameAxisLimits
seems to give a tight(ish) bounding box, the exact opposite of what one would expect.
If you can cure this it means a big boost to my productivity (and that of my research student and other colleagues on my team). Maybe I've misunderstood something, but it looks to me like a serious bug, or a design fault, in Matlab graphics.
1 Commento
Jan
il 5 Lug 2015
I do not understand, what you are looking for. The print'ed version is expected to differ from the display as a Matlab figure. This is the meaning of the property "PaperPosition". print together with this property allows to create PNGs in the wanted size. As far as I understand print works as expected and can create images as specified. So why are you looking for a method to modify the figure window such, that it equals the PNG?
Initially you are talking about PDF or EPS files. But the example concerns PNG files. Which file type is wanted?
Risposte (1)
Jan
il 5 Lug 2015
As usual I ask, if you have tried to solve the problem by using http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig
0 Commenti
Vedere anche
Categorie
Scopri di più su Printing and Saving in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!