-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Certain unicode in Matplotlib + LaTeX #20262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's generally said not to use |
We actually use latex, not pdflatex. The reason is that we need to get dvi output, not pdf output, so that we can parse it and extract glyphs and then position them correctly for pdf and svg output. Currently agg uses dvipng to convert the dvi to png and embed the bitmap and ps uses a completely different codepath, but I would like them to also switch to the "extract-glyphs-from-dvi" approach; I guess that may be part of @aitikgupta's gsoc (mplcairo uses that approach for everything). In fact both xetex and luatex can generate output in a dvi-like format (xdv for xetex) with extensions to support specifying any font on the filesystem, so they should be usable for that purpose as well, but that would require quite a bit of reworking of |
One simpler possibility, though, may be to move the user preamble to the top and rewrite all our |
Looking at this again, one solution may be to just add a bunch of rcParams["text.latex.preamble"] = r"\DeclareUnicodeCharacter{0394}{\ensuremath{\Delta}}"
figtext(.5, .5, "Δ", usetex=True) works. In fact we already mostly have a tex<->unicode mapping in _mathtext_data (tex2uni), so we could use that to generate the preamble. The main problem I can see is that this table actually contains too many entries, some of which (e.g. |
The following code fails at
set_ylabel
:It works with
$\Delta$
instead of Δ and it works if I unsettext.usetex
.The generated tex is this:
and it compiles fine with pdflatex if I replace
\usepackage[utf8]{inputenc}
by\usepackage[utf8x]{inputenc}
. Otherwise the error is the same:I think this is on the side of unexpected behavior.
Versions:
Python 3.8.5
andmatplotlib==3.4.1
.The text was updated successfully, but these errors were encountered: