Which way of exporting Matlab graphics delivers the best result for inclusion in LaTeX? Is it possible to export scalable vector graphics, or even LaTeX graphics?
[Tex/LaTex] the best way to include Matlab graphics
graphicsMATLAB
Related Solutions
If I were you, I would do the following:
In order to make your common settings accessible for all figures, diagrams, documents, etc, put the settings into a single package, namely,
mycommon.sty
. Register this package globally so you can use it throughout your projects. If you don't know how to do this, see my answer here (click).If you want your diagram or figures to be accessible for other projects, put them in a separate directory that is higher than the project directories. For example,
<any directory>\Diagrams\ <any directory>\Diagrams\Projects\Project-01\ <any directory>\Diagrams\Projects\Project-02\
To get a tight drawing for each diagram, use
standalone
document class as follows\documentclass[pstricks,border=12pt,12pt]{standalone} \usepackage{mycommon} \begin{document} % your drawing code goes here... \end{document}
Also load your package for common settings.
Compile each diagram with the appropriate compilers to get a PDF version. It will save a lot of your time when compiling the main input file of your projects.
Import the PDF diagrams from within the main input file of your projects. And compile the main input file with
pdflatex
(recommended because it is fully supported bymicrotype
package). You may also load themycommon
package if necessary.\includegraphics
fromgraphicx
will do the job of importing diagrams. You can set\graphicspath{{../../Diagrams/}}
to shorten your path when invoking\includegraphics
.
My usual practice is to export MATLAB figures as .pdf files, because they are readily recognizable by PDFTEX and are rendered as vectorized images so resizing does not affect quality. The following is a nice MATLAB extension that works great for exporting figures as .pdf without the problem of exporting the image as a whole page:
http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig
It also has a nice documentation page: https://sites.google.com/site/oliverwoodford/software/export_fig
Best Answer
In case the kind of graphics you wish to export is supported by
matlab2tikz
, there is only one way to go:matlab2tikz
.You get true vector graphics in TikZ, i.e., no fiddling with PostScript, being restricted to
latex
, no going back and redoing graphics when your font or color scheme changes, small changes in for instance the legend are done in-place, ...