@@ -125,6 +125,8 @@ def __init__(self,
125125 usetex = None , # defaults to rcParams['text.usetex']
126126 wrap = False ,
127127 transform_rotates_text = False ,
128+ * ,
129+ parse_math = True ,
128130 ** kwargs
129131 ):
130132 """
@@ -142,6 +144,7 @@ def __init__(self,
142144 color if color is not None else mpl .rcParams ["text.color" ])
143145 self .set_fontproperties (fontproperties )
144146 self .set_usetex (usetex )
147+ self .set_parse_math (parse_math )
145148 self .set_wrap (wrap )
146149 self .set_verticalalignment (verticalalignment )
147150 self .set_horizontalalignment (horizontalalignment )
@@ -1237,6 +1240,8 @@ def _preprocess_math(self, s):
12371240 if s == " " :
12381241 s = r"\ "
12391242 return s , "TeX"
1243+ elif not self .get_parse_math ():
1244+ return s , False
12401245 elif cbook .is_math_text (s ):
12411246 return s , True
12421247 else :
@@ -1274,6 +1279,25 @@ def get_usetex(self):
12741279 """Return whether this `Text` object uses TeX for rendering."""
12751280 return self ._usetex
12761281
1282+ def set_parse_math (self , parse_math ):
1283+ """
1284+ Override switch to enable/disable any mathtext
1285+ parsing for the given `Text` object.
1286+
1287+ Parameters
1288+ ----------
1289+ parse_math : bool
1290+ Whether to consider mathtext parsing for the string
1291+ """
1292+ self ._parse_math = bool (parse_math )
1293+
1294+ def get_parse_math (self ):
1295+ """
1296+ Return whether mathtext parsing is considered
1297+ for this `Text` object.
1298+ """
1299+ return self ._parse_math
1300+
12771301 def set_fontname (self , fontname ):
12781302 """
12791303 Alias for `set_family`.
0 commit comments