Open
Description
Bug summary
FigureCanvasPgf
does not use xelatex
but uses pdflatex
.
Code for reproduction
"""
============
PGF preamble
modified from the official example:
https://matplotlib.org/stable/users/explain/text/pgf.html#custom-preamble
============
"""
import matplotlib as mpl
import matplotlib.pyplot as plt
# "The last method allows you to keep using regular interactive backends and to save xelatex, lualatex or pdflatex compiled PDF files from the graphical user interface." said by tutorial
from matplotlib.backends.backend_pgf import FigureCanvasPgf
mpl.backend_bases.register_backend("pdf", FigureCanvasPgf)
# mpl.use("pgf") # uncomment to work!
plt.rcParams.update(
{
"font.family": "serif", # use serif/main font for text elements
"text.usetex": True, # use inline math for ticks
"pgf.rcfonts": False, # don't setup fonts from rc parameters
"pgf.preamble": "\n".join(
[
r"\usepackage{url}", # load additional packages
r"\usepackage{unicode-math}", # unicode math setup
r"\setmainfont{DejaVu Serif}", # serif font via preamble
]
),
}
)
fig, ax = plt.subplots(figsize=(4.5, 2.5))
ax.plot(range(5))
ax.set_xlabel("unicode text: я, ψ, €, ü")
ax.set_ylabel(r"\url{https://matplotlib.org}")
ax.legend(["unicode math: $λ=∑_i^∞ μ_i^2$"])
fig.tight_layout(pad=0.5)
plt.show()
Actual outcome
RuntimeError: latex was not able to process the following string:
b'unicode text: \\u044f, \\u03c8, \\u20ac, \\xfc'
Here is the full command invocation and its output:
latex -interaction=nonstopmode --halt-on-error --output-directory=tmpsm7x8wc7 077a9af4443e140dcb75f16b8d670c44.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024[/Arch](http://localhost:8888/Arch) Linux) (preloaded format=latex)
restricted \write18 enabled.
RuntimeError: latex was not able to process the following string:
b'unicode text: \\u044f, \\u03c8, \\u20ac, \\xfc'
Here is the full command invocation and its output:
latex -interaction=nonstopmode --halt-on-error --output-directory=tmpsm7x8wc7 077a9af4443e140dcb75f16b8d670c44.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024[/Arch](http://localhost:8888/Arch) Linux) (preloaded format=latex)
restricted \write18 enabled.
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[1], line 37
34 ax.set_ylabel(r"\url{https://matplotlib.org}")
35 ax.legend(["unicode math: $λ=∑_i^∞ μ_i^2$"])
---> 37 fig.tight_layout(pad=0.5)
38 plt.show()
39 # fig.savefig("/tmp/test.pdf")
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/figure.py:3540](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/figure.py#line=3539), in Figure.tight_layout(self, pad, h_pad, w_pad, rect)
3538 previous_engine = self.get_layout_engine()
3539 self.set_layout_engine(engine)
-> 3540 engine.execute(self)
3541 if previous_engine is not None and not isinstance(
3542 previous_engine, (TightLayoutEngine, PlaceHolderLayoutEngine)
3543 ):
3544 _api.warn_external('The figure layout has changed to tight')
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/layout_engine.py:183](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/layout_engine.py#line=182), in TightLayoutEngine.execute(self, fig)
181 renderer = fig._get_renderer()
182 with getattr(renderer, "_draw_disabled", nullcontext)():
--> 183 kwargs = get_tight_layout_figure(
184 fig, fig.axes, get_subplotspec_list(fig.axes), renderer,
185 pad=info['pad'], h_pad=info['h_pad'], w_pad=info['w_pad'],
186 rect=info['rect'])
187 if kwargs:
188 fig.subplots_adjust(**kwargs)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/_tight_layout.py:266](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/_tight_layout.py#line=265), in get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad, h_pad, w_pad, rect)
261 return {}
262 span_pairs.append((
263 slice(ss.rowspan.start * div_row, ss.rowspan.stop * div_row),
264 slice(ss.colspan.start * div_col, ss.colspan.stop * div_col)))
--> 266 kwargs = _auto_adjust_subplotpars(fig, renderer,
267 shape=(max_nrows, max_ncols),
268 span_pairs=span_pairs,
269 subplot_list=subplot_list,
270 ax_bbox_list=ax_bbox_list,
271 pad=pad, h_pad=h_pad, w_pad=w_pad)
273 # kwargs can be none if tight_layout fails...
274 if rect is not None and kwargs is not None:
275 # if rect is given, the whole subplots area (including
276 # labels) will fit into the rect instead of the
(...)
280 # auto_adjust_subplotpars twice, where the second run
281 # with adjusted rect parameters.
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/_tight_layout.py:82](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/_tight_layout.py#line=81), in _auto_adjust_subplotpars(fig, renderer, shape, span_pairs, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
80 for ax in subplots:
81 if ax.get_visible():
---> 82 bb += [martist._get_tightbbox_for_layout_only(ax, renderer)]
84 tight_bbox_raw = Bbox.union(bb)
85 tight_bbox = fig.transFigure.inverted().transform_bbox(tight_bbox_raw)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:1411](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=1410), in _get_tightbbox_for_layout_only(obj, *args, **kwargs)
1405 """
1406 Matplotlib's `.Axes.get_tightbbox` and `.Axis.get_tightbbox` support a
1407 *for_layout_only* kwarg; this helper tries to use the kwarg but skips it
1408 when encountering third-party subclasses that do not support it.
1409 """
1410 try:
-> 1411 return obj.get_tightbbox(*args, **{**kwargs, "for_layout_only": True})
1412 except TypeError:
1413 return obj.get_tightbbox(*args, **kwargs)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/_api/deprecation.py:454](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/_api/deprecation.py#line=453), in make_keyword_only.<locals>.wrapper(*args, **kwargs)
448 if len(args) > name_idx:
449 warn_deprecated(
450 since, message="Passing the %(name)s %(obj_type)s "
451 "positionally is deprecated since Matplotlib %(since)s; the "
452 "parameter will become keyword-only %(removal)s.",
453 name=name, obj_type=f"parameter of {func.__name__}()")
--> 454 return func(*args, **kwargs)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/axes/_base.py:4395](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/axes/_base.py#line=4394), in _AxesBase.get_tightbbox(self, renderer, call_axes_locator, bbox_extra_artists, for_layout_only)
4393 for axis in self._axis_map.values():
4394 if self.axison and axis.get_visible():
-> 4395 ba = martist._get_tightbbox_for_layout_only(axis, renderer)
4396 if ba:
4397 bb.append(ba)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:1411](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=1410), in _get_tightbbox_for_layout_only(obj, *args, **kwargs)
1405 """
1406 Matplotlib's `.Axes.get_tightbbox` and `.Axis.get_tightbbox` support a
1407 *for_layout_only* kwarg; this helper tries to use the kwarg but skips it
1408 when encountering third-party subclasses that do not support it.
1409 """
1410 try:
-> 1411 return obj.get_tightbbox(*args, **{**kwargs, "for_layout_only": True})
1412 except TypeError:
1413 return obj.get_tightbbox(*args, **kwargs)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/axis.py:1352](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/axis.py#line=1351), in Axis.get_tightbbox(self, renderer, for_layout_only)
1350 # take care of label
1351 if self.label.get_visible():
-> 1352 bb = self.label.get_window_extent(renderer)
1353 # for constrained[/tight_layout](http://localhost:8888/tight_layout), we want to ignore the label's
1354 # width[/height](http://localhost:8888/height) because the adjustments they make can't be improved.
1355 # this code collapses the relevant direction
1356 if for_layout_only:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:956](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=955), in Text.get_window_extent(self, renderer, dpi)
951 raise RuntimeError(
952 "Cannot get window extent of text w[/o](http://localhost:8888/o) renderer. You likely "
953 "want to call 'figure.draw_without_rendering()' first.")
955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956 bbox, info, descent = self._get_layout(self._renderer)
957 x, y = self.get_unitless_position()
958 x, y = self.get_transform().transform((x, y))
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:381](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=380), in Text._get_layout(self, renderer)
379 clean_line, ismath = self._preprocess_math(line)
380 if clean_line:
--> 381 w, h, d = _get_text_metrics_with_cache(
382 renderer, clean_line, self._fontproperties,
383 ismath=ismath, dpi=self.figure.dpi)
384 else:
385 w = h = d = 0
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:69](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=68), in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:77](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=76), in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py#line=212), in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/backend_bases.py:652](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/backend_bases.py#line=651), in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py:363](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py#line=362), in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
361 if tex.strip() == '':
362 return 0, 0, 0
--> 363 dvifile = cls.make_dvi(tex, fontsize)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py:295](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py#line=294), in TexManager.make_dvi(cls, tex, fontsize)
293 with TemporaryDirectory(dir=cwd) as tmpdir:
294 tmppath = Path(tmpdir)
--> 295 cls._run_checked_subprocess(
296 ["latex", "-interaction=nonstopmode", "--halt-on-error",
297 f"--output-directory={tmppath.name}",
298 f"{texfile.name}"], tex, cwd=cwd)
299 (tmppath [/](http://localhost:8888/) Path(dvifile).name).replace(dvifile)
300 return dvifile
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py:258](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py#line=257), in TexManager._run_checked_subprocess(cls, command, tex, cwd)
254 raise RuntimeError(
255 f'Failed to process string with tex because {command[0]} '
256 'could not be found') from exc
257 except subprocess.CalledProcessError as exc:
--> 258 raise RuntimeError(
259 '{prog} was not able to process the following string:\n'
260 '{tex!r}\n\n'
261 'Here is the full command invocation and its output:\n\n'
262 '{format_command}\n\n'
263 '{exc}\n\n'.format(
264 prog=command[0],
265 format_command=cbook._pformat_subprocess(command),
266 tex=tex.encode('unicode_escape'),
267 exc=exc.output.decode('utf-8', 'backslashreplace'))
268 ) from None
269 _log.debug(report)
270 return report
RuntimeError: latex was not able to process the following string:
b'unicode text: \\u044f, \\u03c8, \\u20ac, \\xfc'
Here is the full command invocation and its output:
latex -interaction=nonstopmode --halt-on-error --output-directory=tmpsm7x8wc7 077a9af4443e140dcb75f16b8d670c44.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024[/Arch](http://localhost:8888/Arch) Linux) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
(./077a9af4443e140dcb75f16b8d670c44.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-02-20>
([/usr/share/texmf-dist/tex/latex/base/article.cls](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/article.cls)
Document Class: article 2023[/05/17](http://localhost:8888/05/17) v1.4n Standard LaTeX document class
([/usr/share/texmf-dist/tex/latex/base/size10.clo](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/size10.clo)))
([/usr/share/texmf-dist/tex/latex/type1cm/type1cm.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/type1cm/type1cm.sty))
([/usr/share/texmf-dist/tex/latex/cm-super/type1ec.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/cm-super/type1ec.sty)
([/usr/share/texmf-dist/tex/latex/base/t1cmr.fd](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/t1cmr.fd)))
([/usr/share/texmf-dist/tex/latex/base/inputenc.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/inputenc.sty))
([/usr/share/texmf-dist/tex/latex/geometry/geometry.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/geometry/geometry.sty)
([/usr/share/texmf-dist/tex/latex/graphics/keyval.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/graphics/keyval.sty))
([/usr/share/texmf-dist/tex/generic/iftex/ifvtex.sty](http://localhost:8888/usr/share/texmf-dist/tex/generic/iftex/ifvtex.sty)
([/usr/share/texmf-dist/tex/generic/iftex/iftex.sty](http://localhost:8888/usr/share/texmf-dist/tex/generic/iftex/iftex.sty))))
([/usr/share/texmf-dist/tex/latex/underscore/underscore.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/underscore/underscore.sty))
([/usr/share/texmf-dist/tex/latex/firstaid/underscore-ltx.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/firstaid/underscore-ltx.sty))
([/usr/share/texmf-dist/tex/latex/base/textcomp.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/textcomp.sty))
([/usr/share/texmf-dist/tex/latex/l3backend/l3backend-dvips.def](http://localhost:8888/usr/share/texmf-dist/tex/latex/l3backend/l3backend-dvips.def))
No file 077a9af4443e140dcb75f16b8d670c44.aux.
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
! LaTeX Error: Unicode character я (U+044F)
not set up for use with LaTeX.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.29 {\rmfamily unicode text: я
, ψ, €, ü}%
No pages of output.
Transcript written on tmpsm7x8wc7[/077a9af4443e140dcb75f16b8d670c44.log.](http://localhost:8888/077a9af4443e140dcb75f16b8d670c44.log.)
Error in callback <function _draw_all_if_interactive at 0x7feb602cc7c0> (for post_execute), with arguments args (),kwargs {}:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/pyplot.py:197](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/pyplot.py#line=196), in _draw_all_if_interactive()
195 def _draw_all_if_interactive() -> None:
196 if matplotlib.is_interactive():
--> 197 draw_all()
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py:132](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py#line=131), in Gcf.draw_all(cls, force)
130 for manager in cls.get_all_fig_managers():
131 if force or manager.canvas.figure.stale:
--> 132 manager.canvas.draw_idle()
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/backend_bases.py:1893](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/backend_bases.py#line=1892), in FigureCanvasBase.draw_idle(self, *args, **kwargs)
1891 if not self._is_idle_drawing:
1892 with self._idle_draw_cntx():
-> 1893 self.draw(*args, **kwargs)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py#line=387), in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:95](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=94), in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:72](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=71), in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/figure.py:3154](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/figure.py#line=3153), in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/image.py:132](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/image.py#line=131), in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:72](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=71), in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/axes/_base.py#line=3069), in _AxesBase.draw(self, renderer)
3067 if artists_rasterized:
3068 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
3071 renderer, self, artists, self.figure.suppressComposite)
3073 renderer.close_group('axes')
3074 self.stale = False
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/image.py:132](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/image.py#line=131), in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:72](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=71), in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/axis.py:1395](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/axis.py#line=1394), in Axis.draw(self, renderer, *args, **kwargs)
1393 # Shift label away from axes to avoid overlapping ticklabels.
1394 self._update_label_position(renderer)
-> 1395 self.label.draw(renderer)
1397 self._update_offset_text_position(tlb1, tlb2)
1398 self.offsetText.set_text(self.major.formatter.get_offset())
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:72](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=71), in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:748](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=747), in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:381](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=380), in Text._get_layout(self, renderer)
379 clean_line, ismath = self._preprocess_math(line)
380 if clean_line:
--> 381 w, h, d = _get_text_metrics_with_cache(
382 renderer, clean_line, self._fontproperties,
383 ismath=ismath, dpi=self.figure.dpi)
384 else:
385 w = h = d = 0
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:69](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=68), in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:77](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=76), in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py#line=212), in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/backend_bases.py:652](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/backend_bases.py#line=651), in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py:363](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py#line=362), in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
361 if tex.strip() == '':
362 return 0, 0, 0
--> 363 dvifile = cls.make_dvi(tex, fontsize)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py:295](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py#line=294), in TexManager.make_dvi(cls, tex, fontsize)
293 with TemporaryDirectory(dir=cwd) as tmpdir:
294 tmppath = Path(tmpdir)
--> 295 cls._run_checked_subprocess(
296 ["latex", "-interaction=nonstopmode", "--halt-on-error",
297 f"--output-directory={tmppath.name}",
298 f"{texfile.name}"], tex, cwd=cwd)
299 (tmppath [/](http://localhost:8888/) Path(dvifile).name).replace(dvifile)
300 return dvifile
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py:258](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py#line=257), in TexManager._run_checked_subprocess(cls, command, tex, cwd)
254 raise RuntimeError(
255 f'Failed to process string with tex because {command[0]} '
256 'could not be found') from exc
257 except subprocess.CalledProcessError as exc:
--> 258 raise RuntimeError(
259 '{prog} was not able to process the following string:\n'
260 '{tex!r}\n\n'
261 'Here is the full command invocation and its output:\n\n'
262 '{format_command}\n\n'
263 '{exc}\n\n'.format(
264 prog=command[0],
265 format_command=cbook._pformat_subprocess(command),
266 tex=tex.encode('unicode_escape'),
267 exc=exc.output.decode('utf-8', 'backslashreplace'))
268 ) from None
269 _log.debug(report)
270 return report
RuntimeError: latex was not able to process the following string:
b'unicode text: \\u044f, \\u03c8, \\u20ac, \\xfc'
Here is the full command invocation and its output:
latex -interaction=nonstopmode --halt-on-error --output-directory=tmpb6xko1st 077a9af4443e140dcb75f16b8d670c44.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024[/Arch](http://localhost:8888/Arch) Linux) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
(./077a9af4443e140dcb75f16b8d670c44.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-02-20>
([/usr/share/texmf-dist/tex/latex/base/article.cls](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/article.cls)
Document Class: article 2023[/05/17](http://localhost:8888/05/17) v1.4n Standard LaTeX document class
([/usr/share/texmf-dist/tex/latex/base/size10.clo](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/size10.clo)))
([/usr/share/texmf-dist/tex/latex/type1cm/type1cm.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/type1cm/type1cm.sty))
([/usr/share/texmf-dist/tex/latex/cm-super/type1ec.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/cm-super/type1ec.sty)
([/usr/share/texmf-dist/tex/latex/base/t1cmr.fd](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/t1cmr.fd)))
([/usr/share/texmf-dist/tex/latex/base/inputenc.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/inputenc.sty))
([/usr/share/texmf-dist/tex/latex/geometry/geometry.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/geometry/geometry.sty)
([/usr/share/texmf-dist/tex/latex/graphics/keyval.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/graphics/keyval.sty))
([/usr/share/texmf-dist/tex/generic/iftex/ifvtex.sty](http://localhost:8888/usr/share/texmf-dist/tex/generic/iftex/ifvtex.sty)
([/usr/share/texmf-dist/tex/generic/iftex/iftex.sty](http://localhost:8888/usr/share/texmf-dist/tex/generic/iftex/iftex.sty))))
([/usr/share/texmf-dist/tex/latex/underscore/underscore.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/underscore/underscore.sty))
([/usr/share/texmf-dist/tex/latex/firstaid/underscore-ltx.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/firstaid/underscore-ltx.sty))
([/usr/share/texmf-dist/tex/latex/base/textcomp.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/textcomp.sty))
([/usr/share/texmf-dist/tex/latex/l3backend/l3backend-dvips.def](http://localhost:8888/usr/share/texmf-dist/tex/latex/l3backend/l3backend-dvips.def))
No file 077a9af4443e140dcb75f16b8d670c44.aux.
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
! LaTeX Error: Unicode character я (U+044F)
not set up for use with LaTeX.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.29 {\rmfamily unicode text: я
, ψ, €, ü}%
No pages of output.
Transcript written on tmpb6xko1st[/077a9af4443e140dcb75f16b8d670c44.log.](http://localhost:8888/077a9af4443e140dcb75f16b8d670c44.log.)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File [~/mambaforge/lib/python3.11/site-packages/IPython/core/formatters.py:343](http://localhost:8888/mambaforge/lib/python3.11/site-packages/IPython/core/formatters.py#line=342), in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File [~/mambaforge/lib/python3.11/site-packages/IPython/core/pylabtools.py:152](http://localhost:8888/mambaforge/lib/python3.11/site-packages/IPython/core/pylabtools.py#line=151), in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
149 from matplotlib.backend_bases import FigureCanvasBase
150 FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
153 data = bytes_io.getvalue()
154 if fmt == 'svg':
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/backend_bases.py:2164](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/backend_bases.py#line=2163), in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2161 # we do this instead of `self.figure.draw_without_rendering`
2162 # so that we can inject the orientation
2163 with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2164 self.figure.draw(renderer)
2165 if bbox_inches:
2166 if bbox_inches == "tight":
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:95](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=94), in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:72](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=71), in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/figure.py:3154](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/figure.py#line=3153), in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/image.py:132](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/image.py#line=131), in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:72](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=71), in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/axes/_base.py#line=3069), in _AxesBase.draw(self, renderer)
3067 if artists_rasterized:
3068 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
3071 renderer, self, artists, self.figure.suppressComposite)
3073 renderer.close_group('axes')
3074 self.stale = False
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/image.py:132](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/image.py#line=131), in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:72](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=71), in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/axis.py:1395](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/axis.py#line=1394), in Axis.draw(self, renderer, *args, **kwargs)
1393 # Shift label away from axes to avoid overlapping ticklabels.
1394 self._update_label_position(renderer)
-> 1395 self.label.draw(renderer)
1397 self._update_offset_text_position(tlb1, tlb2)
1398 self.offsetText.set_text(self.major.formatter.get_offset())
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py:72
9E07
](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/artist.py#line=71), in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:748](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=747), in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:381](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=380), in Text._get_layout(self, renderer)
379 clean_line, ismath = self._preprocess_math(line)
380 if clean_line:
--> 381 w, h, d = _get_text_metrics_with_cache(
382 renderer, clean_line, self._fontproperties,
383 ismath=ismath, dpi=self.figure.dpi)
384 else:
385 w = h = d = 0
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:69](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=68), in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/text.py:77](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/text.py#line=76), in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py#line=212), in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/backend_bases.py:652](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/backend_bases.py#line=651), in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py:363](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py#line=362), in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
361 if tex.strip() == '':
362 return 0, 0, 0
--> 363 dvifile = cls.make_dvi(tex, fontsize)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py:295](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py#line=294), in TexManager.make_dvi(cls, tex, fontsize)
293 with TemporaryDirectory(dir=cwd) as tmpdir:
294 tmppath = Path(tmpdir)
--> 295 cls._run_checked_subprocess(
296 ["latex", "-interaction=nonstopmode", "--halt-on-error",
297 f"--output-directory={tmppath.name}",
298 f"{texfile.name}"], tex, cwd=cwd)
299 (tmppath [/](http://localhost:8888/) Path(dvifile).name).replace(dvifile)
300 return dvifile
File [~/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py:258](http://localhost:8888/mambaforge/lib/python3.11/site-packages/matplotlib/texmanager.py#line=257), in TexManager._run_checked_subprocess(cls, command, tex, cwd)
254 raise RuntimeError(
255 f'Failed to process string with tex because {command[0]} '
256 'could not be found') from exc
257 except subprocess.CalledProcessError as exc:
--> 258 raise RuntimeError(
259 '{prog} was not able to process the following string:\n'
260 '{tex!r}\n\n'
261 'Here is the full command invocation and its output:\n\n'
262 '{format_command}\n\n'
263 '{exc}\n\n'.format(
264 prog=command[0],
265 format_command=cbook._pformat_subprocess(command),
266 tex=tex.encode('unicode_escape'),
267 exc=exc.output.decode('utf-8', 'backslashreplace'))
268 ) from None
269 _log.debug(report)
270 return report
RuntimeError: latex was not able to process the following string:
b'unicode text: \\u044f, \\u03c8, \\u20ac, \\xfc'
Here is the full command invocation and its output:
latex -interaction=nonstopmode --halt-on-error --output-directory=tmp0lcpl6of 077a9af4443e140dcb75f16b8d670c44.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024[/Arch](http://localhost:8888/Arch) Linux) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
(./077a9af4443e140dcb75f16b8d670c44.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-02-20>
([/usr/share/texmf-dist/tex/latex/base/article.cls](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/article.cls)
Document Class: article 2023[/05/17](http://localhost:8888/05/17) v1.4n Standard LaTeX document class
([/usr/share/texmf-dist/tex/latex/base/size10.clo](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/size10.clo)))
([/usr/share/texmf-dist/tex/latex/type1cm/type1cm.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/type1cm/type1cm.sty))
([/usr/share/texmf-dist/tex/latex/cm-super/type1ec.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/cm-super/type1ec.sty)
([/usr/share/texmf-dist/tex/latex/base/t1cmr.fd](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/t1cmr.fd)))
([/usr/share/texmf-dist/tex/latex/base/inputenc.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/inputenc.sty))
([/usr/share/texmf-dist/tex/latex/geometry/geometry.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/geometry/geometry.sty)
([/usr/share/texmf-dist/tex/latex/graphics/keyval.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/graphics/keyval.sty))
([/usr/share/texmf-dist/tex/generic/iftex/ifvtex.sty](http://localhost:8888/usr/share/texmf-dist/tex/generic/iftex/ifvtex.sty)
([/usr/share/texmf-dist/tex/generic/iftex/iftex.sty](http://localhost:8888/usr/share/texmf-dist/tex/generic/iftex/iftex.sty))))
([/usr/share/texmf-dist/tex/latex/underscore/underscore.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/underscore/underscore.sty))
([/usr/share/texmf-dist/tex/latex/firstaid/underscore-ltx.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/firstaid/underscore-ltx.sty))
([/usr/share/texmf-dist/tex/latex/base/textcomp.sty](http://localhost:8888/usr/share/texmf-dist/tex/latex/base/textcomp.sty))
([/usr/share/texmf-dist/tex/latex/l3backend/l3backend-dvips.def](http://localhost:8888/usr/share/texmf-dist/tex/latex/l3backend/l3backend-dvips.def))
No file 077a9af4443e140dcb75f16b8d670c44.aux.
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
! LaTeX Error: Unicode character я (U+044F)
not set up for use with LaTeX.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.29 {\rmfamily unicode text: я
, ψ, €, ü}%
No pages of output.
Transcript written on tmp0lcpl6of[/077a9af4443e140dcb75f16b8d670c44.log.](http://localhost:8888/077a9af4443e140dcb75f16b8d670c44.log.)
Expected outcome
It should use xelatex
and works like mpl.use("pgf")
, and then display the plot under the cell.
This works:
"""
============
PGF preamble
============
"""
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.use("pgf")
plt.rcParams.update(
{
"font.family": "serif", # use serif/main font for text elements
"text.usetex": True, # use inline math for ticks
"pgf.rcfonts": False, # don't setup fonts from rc parameters
"pgf.preamble": "\n".join(
[
r"\usepackage{url}", # load additional packages
r"\usepackage{unicode-math}", # unicode math setup
r"\setmainfont{DejaVu Serif}", # serif font via preamble
]
),
}
)
fig, ax = plt.subplots(figsize=(4.5, 2.5))
ax.plot(range(5))
ax.set_xlabel("unicode text: я, ψ, €, ü")
ax.set_ylabel(r"\url{https://matplotlib.org}")
ax.legend(["unicode math: $λ=∑_i^∞ μ_i^2$"])
fig.tight_layout(pad=0.5)
%matplotlib inline # magic code works as expect!
plt.show()
Additional information
No response
Operating system
Arch
Matplotlib Version
3.8.4
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.11.8
Jupyter version
4.1.6
Installation
conda
Metadata
Metadata
Assignees
Labels
No labels