Skip to content

Commit 082add4

Browse files
committed
MNT: fix obvious bug
Static methods do not have access to self.
1 parent 5857410 commit 082add4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/text.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def _get_layout(self, renderer):
355355

356356
baseline = 0
357357
for i, line in enumerate(lines):
358-
clean_line, ismath = self.is_math_text(line)
358+
clean_line, ismath = self.is_math_text(line, self.get_usetex())
359359
if clean_line:
360360
w, h, d = renderer.get_text_width_height_descent(clean_line,
361361
self._fontproperties,
@@ -782,7 +782,7 @@ def draw(self, renderer):
782782
y = y + posy
783783
if renderer.flipy():
784784
y = canvash - y
785-
clean_line, ismath = textobj.is_math_text(line)
785+
clean_line, ismath = textobj.is_math_text(line, self.get_usetex())
786786

787787
if textobj.get_path_effects():
788788
from matplotlib.patheffects import PathEffectRenderer
@@ -1212,7 +1212,7 @@ def set_text(self, s):
12121212
self.stale = True
12131213

12141214
@staticmethod
1215-
def is_math_text(s):
1215+
def is_math_text(s, usetex=None):
12161216
"""
12171217
Returns a cleaned string and a boolean flag.
12181218
The flag indicates if the given string *s* contains any mathtext,
@@ -1222,7 +1222,9 @@ def is_math_text(s):
12221222
"""
12231223
# Did we find an even number of non-escaped dollar signs?
12241224
# If so, treat is as math text.
1225-
if self.get_usetex():
1225+
if usetex is None:
1226+
usetex = rcParams['text.usetex']
1227+
if usetex:
12261228
if s == ' ':
12271229
s = r'\ '
12281230
return s, 'TeX'

0 commit comments

Comments
 (0)