File tree 4 files changed +24
-3
lines changed 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 296
296
# Values other than 0 or 6 have no defined meaning.
297
297
#text.antialiased: True # If True (default), the text will be antialiased.
298
298
# This only affects raster outputs.
299
+ #text.parse_math: True # Use mathtext if there is an even number of unescaped
300
+ # dollar signs.
299
301
300
302
301
303
## ***************************************************************************
Original file line number Diff line number Diff line change @@ -918,6 +918,7 @@ def _convert_validator_spec(key, conv):
918
918
"text.hinting_factor" : validate_int ,
919
919
"text.kerning_factor" : validate_int ,
920
920
"text.antialiased" : validate_bool ,
921
+ "text.parse_math" : validate_bool ,
921
922
922
923
"mathtext.cal" : validate_font_properties ,
923
924
"mathtext.rm" : validate_font_properties ,
Original file line number Diff line number Diff line change @@ -755,6 +755,20 @@ def test_parse_math():
755
755
fig .canvas .draw ()
756
756
757
757
758
+ def test_parse_math_rcparams ():
759
+ # Default is True
760
+ fig , ax = plt .subplots ()
761
+ ax .text (0 , 0 , r"$ \wrong{math} $" )
762
+ with pytest .raises (ValueError , match = 'Unknown symbol' ):
763
+ fig .canvas .draw ()
764
+
765
+ # Setting rcParams to False
766
+ plt .rcParams ['text.parse_math' ] = False
767
+ fig , ax = plt .subplots ()
768
+ ax .text (0 , 0 , r"$ \wrong{math} $" )
769
+ fig .canvas .draw ()
770
+
771
+
758
772
@image_comparison (['text_pdf_font42_kerning.pdf' ], style = 'mpl20' )
759
773
def test_pdf_font42_kerning ():
760
774
plt .rcParams ['pdf.fonttype' ] = 42
Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ def __init__(self,
142
142
wrap = False ,
143
143
transform_rotates_text = False ,
144
144
* ,
145
- parse_math = True ,
145
+ parse_math = None ,
146
146
** kwargs
147
147
):
148
148
"""
@@ -1289,11 +1289,15 @@ def set_parse_math(self, parse_math):
1289
1289
1290
1290
Parameters
1291
1291
----------
1292
- parse_math : bool
1292
+ parse_math : bool or None
1293
1293
If False, this `Text` will never use mathtext. If True, mathtext
1294
1294
will be used if there is an even number of unescaped dollar signs.
1295
+ ``None`` means to use :rc:`text.parse_math`
1295
1296
"""
1296
- self ._parse_math = bool (parse_math )
1297
+ if parse_math is None :
1298
+ self ._parse_math = mpl .rcParams ['text.parse_math' ]
1299
+ else :
1300
+ self ._parse_math = bool (parse_math )
1297
1301
1298
1302
def get_parse_math (self ):
1299
1303
"""Return whether mathtext parsing is considered for this `Text`."""
You can’t perform that action at this time.
0 commit comments