@@ -3488,15 +3488,19 @@ def set_xlabel(self, xlabel, fontdict=None, labelpad=None, *,
3488
3488
f"its corresponding low level keyword "
3489
3489
f"arguments ({ protected_kw } ) are also "
3490
3490
f"supplied" )
3491
- loc = 'center'
3491
+
3492
3492
else :
3493
3493
loc = (loc if loc is not None
3494
3494
else mpl .rcParams ['xaxis.labellocation' ])
3495
- _api .check_in_list (('left' , 'center' , 'right' ), loc = loc )
3496
- if loc == 'left' :
3497
- kwargs .update (x = 0 , horizontalalignment = 'left' )
3498
- elif loc == 'right' :
3499
- kwargs .update (x = 1 , horizontalalignment = 'right' )
3495
+ _api .check_in_list (('left' , 'center' , 'right' ), loc = loc )
3496
+
3497
+ if loc == 'left' :
3498
+ kwargs .update (x = 0 , horizontalalignment = 'left' )
3499
+ elif loc == 'center' :
3500
+ kwargs .update (x = 0.5 , horizontalalignment = 'center' )
3501
+ elif loc == 'right' :
3502
+ kwargs .update (x = 1 , horizontalalignment = 'right' )
3503
+
3500
3504
return self .xaxis .set_label_text (xlabel , fontdict , ** kwargs )
3501
3505
3502
3506
def invert_xaxis (self ):
@@ -3832,15 +3836,19 @@ def set_ylabel(self, ylabel, fontdict=None, labelpad=None, *,
3832
3836
f"its corresponding low level keyword "
3833
3837
f"arguments ({ protected_kw } ) are also "
3834
3838
f"supplied" )
3835
- loc = 'center'
3839
+
3836
3840
else :
3837
3841
loc = (loc if loc is not None
3838
3842
else mpl .rcParams ['yaxis.labellocation' ])
3839
- _api .check_in_list (('bottom' , 'center' , 'top' ), loc = loc )
3840
- if loc == 'bottom' :
3841
- kwargs .update (y = 0 , horizontalalignment = 'left' )
3842
- elif loc == 'top' :
3843
- kwargs .update (y = 1 , horizontalalignment = 'right' )
3843
+ _api .check_in_list (('bottom' , 'center' , 'top' ), loc = loc )
3844
+
3845
+ if loc == 'bottom' :
3846
+ kwargs .update (y = 0 , horizontalalignment = 'left' )
3847
+ elif loc == 'center' :
3848
+ kwargs .update (y = 0.5 , horizontalalignment = 'center' )
3849
+ elif loc == 'top' :
3850
+ kwargs .update (y = 1 , horizontalalignment = 'right' )
3851
+
3844
3852
return self .yaxis .set_label_text (ylabel , fontdict , ** kwargs )
3845
3853
3846
3854
def invert_yaxis (self ):
0 commit comments