@@ -217,22 +217,20 @@ def set_xlabel(self, xlabel, fontdict=None, labelpad=None, *,
217217 """
218218 if labelpad is not None :
219219 self .xaxis .labelpad = labelpad
220- _protected_kw = ['x' , 'horizontalalignment' , 'ha' ]
221- if any ([ k in kwargs for k in _protected_kw ]) :
220+ protected_kw = ['x' , 'horizontalalignment' , 'ha' ]
221+ if { * kwargs } & { * protected_kw } :
222222 if loc is not None :
223- raise TypeError (' Specifying * loc* is disallowed when any of '
224- ' its corresponding low level kwargs {} '
225- ' are supplied as well.' . format ( _protected_kw ) )
223+ raise TypeError (f" Specifying ' loc' is disallowed when any of "
224+ f" its corresponding low level kwargs "
225+ f"( { protected_kw } ) are supplied as well" )
226226 loc = 'center'
227227 else :
228228 loc = loc if loc is not None else rcParams ['xaxis.labellocation' ]
229229 cbook ._check_in_list (('left' , 'center' , 'right' ), loc = loc )
230- if loc == 'right' :
231- kwargs ['x' ] = 1.
232- kwargs ['horizontalalignment' ] = 'right'
233- elif loc == 'left' :
234- kwargs ['x' ] = 0.
235- kwargs ['horizontalalignment' ] = 'left'
230+ if loc == 'left' :
231+ kwargs .update (x = 0 , horizontalalignment = 'left' )
232+ elif loc == 'right' :
233+ kwargs .update (x = 1 , horizontalalignment = 'right' )
236234 return self .xaxis .set_label_text (xlabel , fontdict , ** kwargs )
237235
238236 def get_ylabel (self ):
@@ -272,22 +270,20 @@ def set_ylabel(self, ylabel, fontdict=None, labelpad=None, *,
272270 """
273271 if labelpad is not None :
274272 self .yaxis .labelpad = labelpad
275- _protected_kw = ['y' , 'horizontalalignment' , 'ha' ]
276- if any ([ k in kwargs for k in _protected_kw ]) :
273+ protected_kw = ['y' , 'horizontalalignment' , 'ha' ]
274+ if { * kwargs } & { * protected_kw } :
277275 if loc is not None :
278- raise TypeError (' Specifying * loc* is disallowed when any of '
279- ' its corresponding low level kwargs {} '
280- ' are supplied as well.' . format ( _protected_kw ) )
276+ raise TypeError (f" Specifying ' loc' is disallowed when any of "
277+ f" its corresponding low level kwargs "
278+ f"( { protected_kw } ) are supplied as well" )
281279 loc = 'center'
282280 else :
283281 loc = loc if loc is not None else rcParams ['yaxis.labellocation' ]
284282 cbook ._check_in_list (('bottom' , 'center' , 'top' ), loc = loc )
285- if loc == 'top' :
286- kwargs ['y' ] = 1.
287- kwargs ['horizontalalignment' ] = 'right'
288- elif loc == 'bottom' :
289- kwargs ['y' ] = 0.
290- kwargs ['horizontalalignment' ] = 'left'
283+ if loc == 'bottom' :
284+ kwargs .update (y = 0 , horizontalalignment = 'left' )
285+ elif loc == 'top' :
286+ kwargs .update (y = 1 , horizontalalignment = 'right' )
291287 return self .yaxis .set_label_text (ylabel , fontdict , ** kwargs )
292288
293289 def get_legend_handles_labels (self , legend_handler_map = None ):
0 commit comments