File tree 4 files changed +21
-3
lines changed
4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 301
301
# Values other than 0 or 6 have no defined meaning.
302
302
#text.antialiased: True # If True (default), the text will be antialiased.
303
303
# This only affects raster outputs.
304
+ #text.parse_math: True # Use mathtext if there is an even number of unescaped
305
+ # dollar signs.
304
306
305
307
306
308
## ***************************************************************************
Original file line number Diff line number Diff line change @@ -932,6 +932,7 @@ def _convert_validator_spec(key, conv):
932
932
"text.hinting_factor" : validate_int ,
933
933
"text.kerning_factor" : validate_int ,
934
934
"text.antialiased" : validate_bool ,
935
+ "text.parse_math" : validate_bool ,
935
936
936
937
"mathtext.cal" : validate_font_properties ,
937
938
"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
+ with mpl .rc_context ({'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 @@ -138,11 +138,11 @@ def __init__(self,
138
138
rotation = None ,
139
139
linespacing = None ,
140
140
rotation_mode = None ,
141
- usetex = None , # defaults to rcParams['text.usetex']
141
+ usetex = None ,
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
"""
@@ -163,7 +163,8 @@ def __init__(self,
163
163
color if color is not None else mpl .rcParams ["text.color" ])
164
164
self .set_fontproperties (fontproperties )
165
165
self .set_usetex (usetex )
166
- self .set_parse_math (parse_math )
166
+ self .set_parse_math (parse_math if parse_math is not None else
167
+ mpl .rcParams ['text.parse_math' ])
167
168
self .set_wrap (wrap )
168
169
self .set_verticalalignment (verticalalignment )
169
170
self .set_horizontalalignment (horizontalalignment )
You can’t perform that action at this time.
0 commit comments