2
2
import math
3
3
import numpy as np
4
4
import re
5
- from matplotlib.backends.backend_pgf import (
6
- common_texification as mpl_common_texification,
7
- )
5
+ from matplotlib.backends.backend_pgf import _tex_escape as mpl_tex_escape
8
6
9
7
from . import _color
10
8
11
9
12
- def _common_texification (string):
10
+ def _tex_escape (string):
13
11
# Work around <https://github.com/matplotlib/matplotlib/issues/15493>
14
- return mpl_common_texification (string).replace("&", "\\&")
12
+ return mpl_tex_escape (string).replace("&", "\\&")
15
13
16
14
def _siunitx_texification(string: str) -> str:
17
15
string = re.sub(r"\smm", r" \\si{\\mm}", string)
@@ -58,14 +56,14 @@ def __init__(self, data, obj): # noqa: C901
58
56
title = obj.get_title()
59
57
data["current axis title"] = title
60
58
if title:
61
- title = _common_texification (title)
59
+ title = _tex_escape (title)
62
60
title = _siunitx_texification(title)
63
61
self.axis_options.append(f"title={{{title}}}")
64
62
65
63
# get axes titles
66
64
xlabel = obj.get_xlabel()
67
65
if xlabel:
68
- xlabel = _common_texification (xlabel)
66
+ xlabel = _tex_escape (xlabel)
69
67
xlabel = _siunitx_texification(xlabel)
70
68
71
69
labelcolor = obj.xaxis.label.get_c()
@@ -86,7 +84,7 @@ def __init__(self, data, obj): # noqa: C901
86
84
87
85
ylabel = obj.get_ylabel()
88
86
if ylabel:
89
- ylabel = _common_texification (ylabel)
87
+ ylabel = _tex_escape (ylabel)
90
88
ylabel = _siunitx_texification(ylabel)
91
89
92
90
ylabel_spl = ylabel.split(",")
@@ -630,7 +628,7 @@ def _get_ticks(data, xy, ticks, ticklabels):
630
628
label = ticklabel.get_text()
631
629
if "," in label:
632
630
label = "{" + label + "}"
633
- pgfplots_ticklabels.append(_common_texification (label))
631
+ pgfplots_ticklabels.append(_tex_escape (label))
634
632
635
633
# note: ticks may be present even if labels are not, keep them for grid lines
636
634
for tick in ticks:
0 commit comments