Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Summary
Currently, postscript output with text.usetex=True is always distilled with ghostscript if the latter is available, regardless ofrcParams["ps.usedistiller"]
:
matplotlib/lib/matplotlib/backends/backend_ps.py
Lines 1096 to 1100 in60d0c33
if (mpl.rcParams['ps.usedistiller']=='ghostscript' | |
ormpl.rcParams['text.usetex']): | |
_try_distill(gs_distill, | |
tmpfile,is_eps,ptype=papertype,bbox=bbox, | |
rotated=psfrag_rotated) |
Comments in the source file and docs (the usetex tutorial) state that
In order to produce encapsulated PostScript (EPS) files that can be embedded in a new LaTeX document, the default behavior (NOTE: actually, not configurable other than by uninstalling ghostscript) of Matplotlib is to distill the output, which removes some PostScript operators used by LaTeX that are illegal in an EPS file.
Assuming that most EPS output will be used in tex files is actually probably quite reasonable, and it seems OK to provide some helpful behavior for end users there. But what are these "illegal operators"? It would seem that even without the distillation step, the files are still OK to embed: one can comment out thetry_distill(gs_distill, ...)
line in backend_ps, generate an eps file withrcParams["text.usetex"] = True; plot(); savefig("/tmp/test/test.eps")
, and compile a simple tex document
\documentclass{article}\usepackage{graphicx}\begin{document}\begin{figure}\centering\includegraphics{test.eps}\end{figure}\end{document}
with latex+dvips (we're including eps files, so that's using the "old" latex+dvips approach rather than pdflatex) and see that the resulting test.ps appears to be just fine.
Figuring out whether ghostscript should be run by default is relevant wrt.#22398 (comment).
Proposed fix
No response