File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -653,3 +653,12 @@ def test_buffer_size(fig_test, fig_ref):
653
653
ax = fig_ref .add_subplot ()
654
654
ax .set_yticks ([0 , 1 ])
655
655
ax .set_yticklabels (["€" , "" ])
656
+
657
+
658
+ def test_fontproperties_kwarg_precedence ():
659
+ """Test that kwargs take precedence over fontproperties defaults."""
660
+ plt .figure ()
661
+ text1 = plt .xlabel ("value" , fontproperties = 'Times New Roman' , size = 40.0 )
662
+ text2 = plt .ylabel ("counts" , size = 40.0 , fontproperties = 'Times New Roman' )
663
+ assert text1 .get_size () == 40.0
664
+ assert text2 .get_size () == 40.0
Original file line number Diff line number Diff line change @@ -174,8 +174,12 @@ def __init__(self,
174
174
175
175
def update (self , kwargs ):
176
176
# docstring inherited
177
- # Update bbox last, as it depends on font properties.
178
177
sentinel = object () # bbox can be None, so use another sentinel.
178
+ # Update fontproperties first, as it has lowest priority.
179
+ fontproperties = kwargs .pop ("fontproperties" , sentinel )
180
+ if fontproperties is not sentinel :
181
+ self .set_fontproperties (fontproperties )
182
+ # Update bbox last, as it depends on font properties.
179
183
bbox = kwargs .pop ("bbox" , sentinel )
180
184
super ().update (kwargs )
181
185
if bbox is not sentinel :
You can’t perform that action at this time.
0 commit comments