I am used to plot data with gnuplot, so I can easily put the figures in a LaTeX document, using the epslatex
terminal. For example:
file = "data.dat"
set terminal epslatex
set output "figure1.tex"
plot file
This way, two files are generated: one .eps
file, which contains the graphics, and one .tex
file, which contains the text. The great advantage of this is that text is rendered by LaTeX, so the tics, labels, etc. have the same font as the rest of the document.
Now I am starting with matplotlib, which has a much nicer API, is more scriptable and, well, is Python. But, even though I can make matplotlib render the text with LaTeX, it gets embedded into the image and I cannot achieve the same advantages I had with gnuplot.
Is there any way I can emulate the epslatex terminal in matplotlib?
Update: matplotlib 1.2 introduced a new PGF/TikZ backend, and I have successfully used it for the exact purpose stated in this question: make LaTeX / XeTeX render the text of the plot. In the documentation there are some nice examples of plotting using the PGF backend, including custom preambles, custom fonts and full unicode math support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With