@@ -3488,15 +3488,19 @@ def set_xlabel(self, xlabel, fontdict=None, labelpad=None, *,
34883488 f"its corresponding low level keyword "
34893489 f"arguments ({ protected_kw } ) are also "
34903490 f"supplied" )
3491- loc = 'center'
3491+
34923492 else :
34933493 loc = (loc if loc is not None
34943494 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+
35003504 return self .xaxis .set_label_text (xlabel , fontdict , ** kwargs )
35013505
35023506 def invert_xaxis (self ):
@@ -3832,15 +3836,19 @@ def set_ylabel(self, ylabel, fontdict=None, labelpad=None, *,
38323836 f"its corresponding low level keyword "
38333837 f"arguments ({ protected_kw } ) are also "
38343838 f"supplied" )
3835- loc = 'center'
3839+
38363840 else :
38373841 loc = (loc if loc is not None
38383842 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+
38443852 return self .yaxis .set_label_text (ylabel , fontdict , ** kwargs )
38453853
38463854 def invert_yaxis (self ):
0 commit comments