I realize this question might have been asked already, but I'm relatively new to LaTeX and matlab so I need some help.
I'm trying to export a figure for inclusion in my tex
document (to be compiled using pdflatex
). The figure contains axes labels with LaTeX fonts (xlabel(...,'interpreter',latex)
).
I've looked extensevely on the web but have not found a satisfactory solution.
My best solution so far is to produce a png file by using the savefig.m
function, but the quality is not ideal
I'd be very grateful for any hints.
Best Answer
These are the possibilities for you (I use the first two for my work):
Way out 1
You may try matlab2tikz and export your figures into
tikz
code.Way out 2
Try matfig2pgf and get
pgf
code for your figure. matfig2pgf also provides a nice menu in the matlab figure window, thus some what more friendly.Way out 3
If you a a PSTricks fan try fig2texps and get pstricks code.
Way out 4
Try plot2svg and get svg diagrams. But this is somewhat over kill as you have to again find ways to insert svg figures into latex.
Way out 5
If you have surface plots, you may look at surf2latex.
You can search for other applications in mathworks matlabcentral/fileexchange and look for various (numerous) ways. Also use different key words like pgf, tikz, PSTricks, latex etc in your search on that page. Hope this is useful.
How to get some peace of mind
For all plotting needs you may start using
pgfplots
. Use matlab to get the datapoints from your program, and usepgfplots
to plot. For details, see pgfplots documentation.pgfplots
can also be used with gnuplot seemlessly. Hence we can use the computing capabilities of gnuplot also.An example:
You need to have
gnuplot
installed for this to work and enable--shell-escape
option forpdflatex
.