Description
Summary
Currently, postscript output with text.usetex=True is always distilled with ghostscript if the latter is available, regardless of rcParams["ps.usedistiller"]
:
matplotlib/lib/matplotlib/backends/backend_ps.py
Lines 1096 to 1100 in 60d0c33
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 the try_distill(gs_distill, ...)
line in backend_ps, generate an eps file with rcParams["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