You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Exponential numbers on axis look like 10Σ² instead of 10⁻² with backend_gtk3cairo #32084
changed the title [-][Bug]: Exponential numbers on axis look like 10Σ² instead of 10⁻²[/-][+][Bug]: Exponential numbers on axis look like 10Σ² instead of 10⁻² with backend_gtk3cairo[/+]on Jul 21, 2026
Is there a reason you are using the Gtk3Cairo backend over the Gtk3Agg one? The Cairo backends tend to be less well tested and featureful. If you really want to use Cairo, it may be better to use mplcairo.
The problem here is that both Pycairo and cairocffi only support the toy font face API in Cairo. The toy font face API only supports selecting a font with a family name (plus some modifiers) and no explicit path. In 3.11, we switched from sending characters directly to Cairo and instead using the glyphs selected by libraqm. This is slightly less of the toy API since Cairo doesn't expose any way to pick language/font features/alternate glyphs/etc if giving it characters only.
Unfortunately, we ship a copy of DejaVu Sans that isn't the same as the current system one:
AFAICT, Cairo passes that family to fontconfig and doesn't parse it as a fontconfig pattern, so we can't even do a trick like pass :file=/path/to/DejaVuSans.ttf (and in any case, it would only accept explicit paths that are in the fontconfig system/user path not our arbitrary file.)
There are two possible fixes:
Go back to character codes. Since that is the toy API, it probably means that alternate glyphs and font settings won't work properly.
Manually load the other non-toy API in the same way as mplcairo does. This is a lot more work as we need to handle all the different ways that Cairo might be loaded.
Though now that I look at it closer, regular text doesn't go through libraqm for the Cairo backends; they just use show_text with the characters. So it is likely safe enough to revert mathtext to characters again, as it will work about the same as it used to (which is to say not perfectly, but likely good enough.)
That being said, since the Cairo backends don't support full internationalization and other advanced font features, I'd highly recommend switching to one of the Agg backends.
@QuLogic I could trace my decision of switching from Agg to Cairo to solving AttributeError: 'FigureCanvasTk' object has no attribute 'set_size_request' error few years ago. It seems this error got meanwhile addressed here. Or maybe AI will help me switch back to Agg once I get to full refactoring my application. I love the capabilities of Matplotlib, but I must say programming GUI with Matplotlib backends hasn't been an entirely smooth experience for me.
Activity
rcomer commentedon Jul 21, 2026
Hi @FilipDominec thanks for the report. Please could you provide a complete code example we can run?
rcomer commentedon Jul 21, 2026
With our
maindevelopment branch andI get
FilipDominec commentedon Jul 21, 2026
@rcomer , I got the wrong result above using a GUI frontend (https://github.com/FilipDominec/nihilnovi/), whereas typing out a minimum standalone working example like
gives correct axes, as you show above.
So I will dig into my codes to trace down what option I use there that triggers the new error.
FilipDominec commentedon Jul 21, 2026
In a short standalone script, I couldn't reproduce the error with the explicit matplotlib & backends configuration I am using in the graphical app.
But asking Claude to sketch a simple plotting GUI isolates the error (scripts attached).
b-cairo.py
b-tk.py
It seems to me there might be some recent change in the
matplotlib.backends.backend_gtk3cairo.[-][Bug]: Exponential numbers on axis look like 10Σ² instead of 10⁻²[/-][+][Bug]: Exponential numbers on axis look like 10Σ² instead of 10⁻² with backend_gtk3cairo[/+]QuLogic commentedon Jul 21, 2026
Is there a reason you are using the Gtk3Cairo backend over the Gtk3Agg one? The Cairo backends tend to be less well tested and featureful. If you really want to use Cairo, it may be better to use mplcairo.
QuLogic commentedon Jul 22, 2026
The problem here is that both Pycairo and cairocffi only support the toy font face API in Cairo. The toy font face API only supports selecting a font with a family name (plus some modifiers) and no explicit path. In 3.11, we switched from sending characters directly to Cairo and instead using the glyphs selected by libraqm. This is slightly less of the toy API since Cairo doesn't expose any way to pick language/font features/alternate glyphs/etc if giving it characters only.
Unfortunately, we ship a copy of DejaVu Sans that isn't the same as the current system one:
AFAICT, Cairo passes that family to fontconfig and doesn't parse it as a fontconfig pattern, so we can't even do a trick like pass
:file=/path/to/DejaVuSans.ttf(and in any case, it would only accept explicit paths that are in the fontconfig system/user path not our arbitrary file.)There are two possible fixes:
QuLogic commentedon Jul 22, 2026
Though now that I look at it closer, regular text doesn't go through libraqm for the Cairo backends; they just use
show_textwith the characters. So it is likely safe enough to revert mathtext to characters again, as it will work about the same as it used to (which is to say not perfectly, but likely good enough.)That being said, since the Cairo backends don't support full internationalization and other advanced font features, I'd highly recommend switching to one of the Agg backends.
FilipDominec commentedon Jul 22, 2026
@QuLogic I could trace my decision of switching from Agg to Cairo to solving
AttributeError: 'FigureCanvasTk' object has no attribute 'set_size_request'error few years ago. It seems this error got meanwhile addressed here. Or maybe AI will help me switch back to Agg once I get to full refactoring my application. I love the capabilities of Matplotlib, but I must say programming GUI with Matplotlib backends hasn't been an entirely smooth experience for me.Cairo: Switch back to character codes for mathtext