Skip to content

Commit 9eddaba

Browse files
committed
replacing deprecated mpl function common_texification with _tex_escape to hopefully fix matplotlib 3.6 deprecates pgf.common_texification nschloe#559
1 parent 51d8e0f commit 9eddaba

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/tikzplotlib/_axes.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import matplotlib as mpl
22
import numpy as np
3-
from matplotlib.backends.backend_pgf import (
4-
common_texification as mpl_common_texification,
5-
)
3+
from matplotlib.backends.backend_pgf import _tex_escape as mpl_tex_escape
64

75
from . import _color
86

97

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

1412

1513
class Axes:
@@ -42,13 +40,13 @@ def __init__(self, data, obj): # noqa: C901
4240
title = obj.get_title()
4341
data["current axis title"] = title
4442
if title:
45-
title = _common_texification(title)
43+
title = _tex_escape(title)
4644
self.axis_options.append(f"title={{{title}}}")
4745

4846
# get axes titles
4947
xlabel = obj.get_xlabel()
5048
if xlabel:
51-
xlabel = _common_texification(xlabel)
49+
xlabel = _tex_escape(xlabel)
5250

5351
labelcolor = obj.xaxis.label.get_c()
5452

@@ -64,7 +62,7 @@ def __init__(self, data, obj): # noqa: C901
6462

6563
ylabel = obj.get_ylabel()
6664
if ylabel:
67-
ylabel = _common_texification(ylabel)
65+
ylabel = _tex_escape(ylabel)
6866

6967
labelcolor = obj.yaxis.label.get_c()
7068
if labelcolor != "black":
@@ -594,7 +592,7 @@ def _get_ticks(data, xy, ticks, ticklabels):
594592
label = ticklabel.get_text()
595593
if "," in label:
596594
label = "{" + label + "}"
597-
pgfplots_ticklabels.append(_common_texification(label))
595+
pgfplots_ticklabels.append(_tex_escape(label))
598596

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

0 commit comments

Comments
 (0)