When ever I want to write a research paper and print the simulated results (by Matlab) into an .eps
file, I think of a direct way of translating Matlab fig files into LaTeX (especially TikZ).
Is there a way to do such a thing?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityWhen ever I want to write a research paper and print the simulated results (by Matlab) into an .eps
file, I think of a direct way of translating Matlab fig files into LaTeX (especially TikZ).
Is there a way to do such a thing?
As mentioned in zuggg's comment, you can convert MATLAB figures to TikZ by using the matlab2tikz
script. What this does is collect the data points and then uses the PGFPlots \addplot table
to recreate the plot. The author wrote the script so that it also works in GNU Octave, but the MATLAB Central license does not allow use of the shared software in non-MathWorks products.
Octave, on the other hand, has built-in export capabilities via the print -dtikz
command. When using the FLTK graphics toolkit, it will generate lower-level PGF commands, and when using Gnuplot, it will generate higher-level TikZ commands. In both cases, the plot is built from basic graphical building blocks (tiny rectangles in some cases) and look inferior to the PGFPlots approach, especially when zoomed in.
Another advantage to the matlab2tikz
script is that it provides key-value arguments which allow you to do this:
matlab2tikz('width', '.8\textwidth')
This also shows that you can specify the plot size in terms of TeX sizes. I didn't find a way to do this with the Octave print
command, and the resulting figures were either too small or too big.