Skip to content

Commit 860e4a5

Browse files
committed
replacing deprecated mpl function common_texification with _tex_escape
1 parent f033122 commit 860e4a5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Diff for: src/tikzplotlib/_axes.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
import math
33
import numpy as np
44
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
86

97
from . import _color
108

119

12-
def _common_texification(string):
10+
def _tex_escape(string):
1311
# Work around <https://github.com/matplotlib/matplotlib/issues/15493>
14-
return mpl_common_texification(string).replace("&", "\\&")
12+
return mpl_tex_escape(string).replace("&", "\\&")
1513

1614
def _siunitx_texification(string: str) -> str:
1715
string = re.sub(r"\smm", r" \\si{\\mm}", string)
@@ -58,14 +56,14 @@ def __init__(self, data, obj): # noqa: C901
5856
title = obj.get_title()
5957
data["current axis title"] = title
6058
if title:
61-
title = _common_texification(title)
59+
title = _tex_escape(title)
6260
title = _siunitx_texification(title)
6361
self.axis_options.append(f"title={{{title}}}")
6462

6563
# get axes titles
6664
xlabel = obj.get_xlabel()
6765
if xlabel:
68-
xlabel = _common_texification(xlabel)
66+
xlabel = _tex_escape(xlabel)
6967
xlabel = _siunitx_texification(xlabel)
7068

7169
labelcolor = obj.xaxis.label.get_c()
@@ -86,7 +84,7 @@ def __init__(self, data, obj): # noqa: C901
8684

8785
ylabel = obj.get_ylabel()
8886
if ylabel:
89-
ylabel = _common_texification(ylabel)
87+
ylabel = _tex_escape(ylabel)
9088
ylabel = _siunitx_texification(ylabel)
9189

9290
ylabel_spl = ylabel.split(",")
@@ -630,7 +628,7 @@ def _get_ticks(data, xy, ticks, ticklabels):
630628
label = ticklabel.get_text()
631629
if "," in label:
632630
label = "{" + label + "}"
633-
pgfplots_ticklabels.append(_common_texification(label))
631+
pgfplots_ticklabels.append(_tex_escape(label))
634632

635633
# note: ticks may be present even if labels are not, keep them for grid lines
636634
for tick in ticks:

0 commit comments

Comments
 (0)