From f9717d11e8bcd11cb64f18e792b3782537407b13 Mon Sep 17 00:00:00 2001 From: Mervin Yap Date: Tue, 16 Jun 2026 12:24:25 +0200 Subject: [PATCH 1/2] FIX: Missing 1 positional argument in RendererBase # PR Summary --- Missing 1 positional argument 'mtext' in `RendererBase._draw_text_as_path()` (line 509 of `backend_bases.py`). Small fix by including `mtext=mtext` into `RendererBase._draw_text_as_path()`. This error happens when the user is trying to use LaTeX in matplotlib with matplotlib==3.11.0. # AI Disclosure --- All errors and fixes were done manually. --- lib/matplotlib/backend_bases.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 27c3752858a7..633ce987269d 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -506,7 +506,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None): mtext : `~matplotlib.text.Text` The original text object to be rendered. """ - self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX") + self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX", mtext=mtext) def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): """ From 3bdf6c2c4c3227a9ee02daa8845b4d89a00ed071 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 26 Jun 2026 16:00:21 -0400 Subject: [PATCH 2/2] Add a smoke test for RendererBase.draw_tex --- lib/matplotlib/tests/test_usetex.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/matplotlib/tests/test_usetex.py b/lib/matplotlib/tests/test_usetex.py index 6d7506055ce5..55bd72ade5bf 100644 --- a/lib/matplotlib/tests/test_usetex.py +++ b/lib/matplotlib/tests/test_usetex.py @@ -44,6 +44,18 @@ def test_usetex(): ax.set_axis_off() +def test_usetex_fallback(monkeypatch): + # Smoke test that the base draw_tex implementation works. + from matplotlib.backend_bases import RendererBase + from matplotlib.backends.backend_agg import RendererAgg + monkeypatch.setattr(RendererAgg, 'draw_tex', RendererBase.draw_tex) + + plt.rcParams["text.usetex"] = True + fig, ax = plt.subplots() + ax.text(0, 0, "foo_bar") + fig.canvas.draw() + + @check_figures_equal(extensions=['png', 'pdf', 'svg']) def test_empty(fig_test, fig_ref): mpl.rcParams['text.usetex'] = True