Mathtext rendering fails with Matplotlib 3.11: glyph tuples now contain six fields
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 72/100
Rechercherichtung
Start by tracing how mplcairo handles MathTextParser("path").parse(...).glyphs and compare its expected tuples with Matplotlib 3.11's six-field tuples. Use the reproducer to confirm the rendering failure, then check both canvas drawing and MultiPage PDF output. Done means the mathtext annotation renders and multipage saving succeeds with Matplotlib 3.11.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Bug summary
Rendering a figure containing mathtext with mplcairo 0.6.1 and
Matplotlib 3.11.2 fails with a C++ type-casting error. This also
affects saving such figures with mplcairo.multipage.MultiPage.
Reproducer
import matplotlib
matplotlib.use("module://mplcairo.base")
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2])
ax.annotate(r"$\sigma_f=1.4\times 10^{-8}$", (1, 1))
fig.canvas.draw()
Actual result
RuntimeError: Unable to cast Python instance of type <class 'tuple'>
to C++ type '?' (#define PYBIND11_DETAILED_ERROR_MESSAGES or
compile in debug mode for details)
Expected result
The figure renders with the mathtext annotation.
Likely cause
Matplotlib 3.11 added a glyph index to each tuple in
MathTextParser("path").parse(...).glyphs. The tuples now contain:
(font, fontsize, character_code, glyph_index, x, y)
The mplcairo renderer appears to cast each tuple to the previous
five-field form. Matplotlib documents the change here:
As a local experiment, adapting the parser result to remove the added
glyph-index field allowed both canvas rendering and multipage PDF
output to complete. This was a compatibility experiment, not a
tested upstream patch.
Environment
Python: 3.15.2
Matplotlib: 3.11.2
mplcairo: 0.6.1
Fedora Linux 45
- Vorherrschende Sprache
- C++
- Sterne
- 120
- Forks
- 23
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus matplotlib/mplcairo
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
matplotlib/mplcairo#55 · 18 Kommentare ·
-
workaround for low dpi when rasterizing (pcolormesh saved as pdf)Evtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
matplotlib/mplcairo#19 · 5 Kommentare ·
Alle Issues in matplotlib/mplcairo
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
simnJS/AnyPS5#735 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:tests kind:test
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
Maintainer antworten meist innerhalb von 1 Tag
-
? - Needs Triage bot_watch bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
NVIDIA/cudf-spark-jni#5594 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Branch-master
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
TrinityCore/TrinityCore#32177 ·
Maintainer antworten meist innerhalb von 10 Tagen