@@ -355,7 +355,7 @@ def _get_layout(self, renderer):
355
355
356
356
baseline = 0
357
357
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 () )
359
359
if clean_line :
360
360
w , h , d = renderer .get_text_width_height_descent (clean_line ,
361
361
self ._fontproperties ,
@@ -782,7 +782,7 @@ def draw(self, renderer):
782
782
y = y + posy
783
783
if renderer .flipy ():
784
784
y = canvash - y
785
- clean_line , ismath = textobj .is_math_text (line )
785
+ clean_line , ismath = textobj .is_math_text (line , self . get_usetex () )
786
786
787
787
if textobj .get_path_effects ():
788
788
from matplotlib .patheffects import PathEffectRenderer
@@ -1212,7 +1212,7 @@ def set_text(self, s):
1212
1212
self .stale = True
1213
1213
1214
1214
@staticmethod
1215
- def is_math_text (s ):
1215
+ def is_math_text (s , usetex = None ):
1216
1216
"""
1217
1217
Returns a cleaned string and a boolean flag.
1218
1218
The flag indicates if the given string *s* contains any mathtext,
@@ -1222,7 +1222,9 @@ def is_math_text(s):
1222
1222
"""
1223
1223
# Did we find an even number of non-escaped dollar signs?
1224
1224
# 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 :
1226
1228
if s == ' ' :
1227
1229
s = r'\ '
1228
1230
return s , 'TeX'
0 commit comments