I’m using matplotlib 0.9.12 from ubuntu hardy 8.04.
To take advantage of the LaTeX handling capability in matplotlib,
I’ve added next two lines in /etc/matplotlib
text.usetex : True
text.latex.preamble : \usepackage{amsmath}
Then, I tried next test code.
from pylab import *
x = []; y = []
figure(figsize=(2,2))
plot(x,y,label=r’$\theta=$0.0deg’); axis([0,1,0,1]); legend()
text(0.5, 0.5, r’\begin{align*}x&=\alpha\y&=\beta\end{align*}’)
savefig(‘test.eps’)
However, I’ve got the following error message without a resulting eps file.
···
====================================================================
Traceback (most recent call last):
File “test.py”, line 6, in
savefig(‘test.eps’)
File “/usr/lib/python2.5/site-packages/matplotlib/pyplot.py”, line 269, in savefig
return fig.savefig(*args, **kwargs)
File “/usr/lib/python2.5/site-packages/matplotlib/figure.py”, line 782, in savefig
self.canvas.print_figure(*args, **kwargs)
File “/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py”, line 1195, in print_figure
**kwargs)
File “/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py”, line 1099, in print_eps
return ps.print_eps(*args, **kwargs)
File “/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py”, line 1018, in print_eps
return self._print_ps(outfile, ‘eps’, *args, **kwargs)
File “/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py”, line 1041, in _print_ps
orientation, isLandscape, papertype)
File “/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py”, line 1289, in _print_figure_tex
orientation)
File “/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py”, line 1376, in convert_psfrags
\nHere is the full report generated by LaTeX: \n\n%s’% fh.read())
RuntimeError: LaTeX was not able to process your file:
Here is the full report generated by LaTeX:
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
%&-line parsing enabled.
entering extended mode
(/tmp/8c18ecc500de49027f0ed1df1bec10b8.tex
LaTeX2e <2005/12/01>
Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, loaded.
(/usr/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size10.clo))
(/usr/share/texmf-texlive/tex/latex/type1cm/type1cm.sty)
(/usr/share/texmf-texlive/tex/latex/psnfss/helvet.sty
(/usr/share/texmf-texlive/tex/latex/graphics/keyval.sty))
(/usr/share/texmf-texlive/tex/latex/psnfss/courier.sty)
(/usr/share/texmf-texlive/tex/latex/base/textcomp.sty
(/usr/share/texmf-texlive/tex/latex/base/ts1enc.def))
(/usr/share/texmf-texlive/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?’ option.
(/usr/share/texmf-texlive/tex/latex/amsmath/amstext.sty
(/usr/share/texmf-texlive/tex/latex/amsmath/amsgen.sty))
(/usr/share/texmf-texlive/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texmf-texlive/tex/latex/amsmath/amsopn.sty))
(/usr/share/texmf-texlive/tex/latex/geometry/geometry.sty
Package geometry Warning: Over-specification in h'-direction.
width’ (614.295pt) is ignored.
Package geometry Warning: Over-specification in v'-direction.
height’ (794.96999pt) is ignored.
) (/usr/share/texmf-texlive/tex/latex/psfrag/psfrag.sty
(/usr/share/texmf-texlive/tex/latex/graphics/graphics.sty
(/usr/share/texmf-texlive/tex/latex/graphics/trig.sty)
(/etc/texmf/tex/latex/config/graphics.cfg)
(/usr/share/texmf-texlive/tex/latex/graphics/dvips.def)))
(/usr/share/texmf-texlive/tex/latex/graphics/graphicx.sty)
(/usr/share/texmf-texlive/tex/latex/graphics/color.sty
(/etc/texmf/tex/latex/config/color.cfg)
(/usr/share/texmf-texlive/tex/latex/graphics/dvipsnam.def))
(./8c18ecc500de49027f0ed1df1bec10b8.aux)
(/usr/share/texmf-texlive/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf-texlive/tex/latex/psnfss/ot1pnc.fd)
<8c18ecc500de49027f0ed1df1bec10b8.eps>
(/usr/share/texmf-texlive/tex/latex/psnfss/ot1phv.fd)
! Missing \endgroup inserted.
\endgroup
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing } inserted.
}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing \endgroup inserted.
\endgroup
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing } inserted.
}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! LaTeX Error: There’s no line here to end.
See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
…
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing $ inserted.
$
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing } inserted.
}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing } inserted.
}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing } inserted.
}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing \cr inserted.
\cr
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing { inserted.
{
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing { inserted.
{
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Extra }, or forgotten $.
}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing $ inserted.
$
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing } inserted.
}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Misplaced alignment tab character &.
x&=\alpha \y&
=\beta
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing $ inserted.
$
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Misplaced \cr.
\math@…1975…@@@ ->\cr
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Misplaced \noalign.
\math@…1975…@@ … \iffalse }\fi \math@…1975…@@@ \noalign
{\vskip #1\relax }
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing $ inserted.
$
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing } inserted.
}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Extra }, or forgotten \endgroup.
\math@…1975…@@ …th@…1975…@@@ \noalign {\vskip #1\relax }
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Misplaced \noalign.
\black@ #1->\noalign
{\ifdim #1>\displaywidth \dimen@ \prevdepth \nointerlin…
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Extra }, or forgotten \endgroup.
\endalign ->\math@…1975… \black@ \totwidth@ \egroup
\ifingather@ \restorealignst…
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! LaTeX Error: \begin{figure} on input line 15 ended by \end{align*}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
…
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing $ inserted.
$
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Display math should end with $$.
\endgroup
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing } inserted.
}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing } inserted.
}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Extra }, or forgotten \endgroup.
\Gin@…1976… …angle {#1}\setbox \z@ \hbox {{#2}}
\Grot@…1977… \z@ \Grot@…1978… \z@ \G…
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Undefined control sequence.
\Grot@…1979…
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing number, treated as zero.
)
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Undefined control sequence.
\Grot@…1979…
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing number, treated as zero.
)
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Undefined control sequence.
\Grot@…1979…
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing number, treated as zero.
)
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Undefined control sequence.
\Grot@…1979…
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Missing number, treated as zero.
)
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Undefined control sequence.
\Grot@…1980… …currentpoint translate \Grot@…1979…
\space neg rotate neg exch…
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Extra }, or forgotten \endgroup.
\mbox #1->\leavevmode \hbox {#1}
l.32 …e=0]{8c18ecc500de49027f0ed1df1bec10b8.eps}
! Too many }'s.
@endfloatbox …pagefalse \outer@…1981… \egroup
\color@…1982…
l.33 \end{figure}
! Extra \endgroup.
\color@…1983… ->\endgraf \endgroup
l.33 \end{figure}
! Too many }'s.
\color@…1982… ->\color@…1983… \egroup
l.33 \end{figure}
! LaTeX Error: \begin{document} ended by \end{figure}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
…
l.33 \end{figure}
! Extra \endgroup.
\endgroup
l.33 \end{figure}
[1] (./8c18ecc500de49027f0ed1df1bec10b8.aux) )
(see the transcript file for additional information)
Output written on 8c18ecc500de49027f0ed1df1bec10b8.dvi (1 page, 424 bytes).
Transcript written on 8c18ecc500de49027f0ed1df1bec10b8.log.
====================================================================
How can I save a plot with a LaTeX environment in eps format?
–
Yong-Duk Jin