@@ -217,22 +217,20 @@ def set_xlabel(self, xlabel, fontdict=None, labelpad=None, *,
217
217
"""
218
218
if labelpad is not None :
219
219
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 } :
222
222
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" )
226
226
loc = 'center'
227
227
else :
228
228
loc = loc if loc is not None else rcParams ['xaxis.labellocation' ]
229
229
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' )
236
234
return self .xaxis .set_label_text (xlabel , fontdict , ** kwargs )
237
235
238
236
def get_ylabel (self ):
@@ -272,22 +270,20 @@ def set_ylabel(self, ylabel, fontdict=None, labelpad=None, *,
272
270
"""
273
271
if labelpad is not None :
274
272
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 } :
277
275
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" )
281
279
loc = 'center'
282
280
else :
283
281
loc = loc if loc is not None else rcParams ['yaxis.labellocation' ]
284
282
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' )
291
287
return self .yaxis .set_label_text (ylabel , fontdict , ** kwargs )
292
288
293
289
def get_legend_handles_labels (self , legend_handler_map = None ):
0 commit comments