Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4971085

Browse files
committed
Tiny cleanups to set_xlabel(..., loc=...).
1 parentcc55b47 commit4971085

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,20 @@ def set_xlabel(self, xlabel, fontdict=None, labelpad=None, *,
217217
"""
218218
iflabelpadisnotNone:
219219
self.xaxis.labelpad=labelpad
220-
_protected_kw= ['x','horizontalalignment','ha']
221-
ifany([kinkwargsforkin_protected_kw]):
220+
protected_kw= ['x','horizontalalignment','ha']
221+
if{*kwargs}& {*protected_kw}:
222222
iflocisnotNone:
223-
raiseTypeError('Specifying*loc* is disallowed when any of'
224-
'its corresponding low level kwargs{} '
225-
'are supplied as well.'.format(_protected_kw))
223+
raiseTypeError(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=lociflocisnotNoneelsercParams['xaxis.labellocation']
229229
cbook._check_in_list(('left','center','right'),loc=loc)
230-
ifloc=='right':
231-
kwargs['x']=1.
232-
kwargs['horizontalalignment']='right'
233-
elifloc=='left':
234-
kwargs['x']=0.
235-
kwargs['horizontalalignment']='left'
230+
ifloc=='left':
231+
kwargs.update(x=0,horizontalalignment='left')
232+
elifloc=='right':
233+
kwargs.update(x=1,horizontalalignment='right')
236234
returnself.xaxis.set_label_text(xlabel,fontdict,**kwargs)
237235

238236
defget_ylabel(self):
@@ -273,21 +271,19 @@ def set_ylabel(self, ylabel, fontdict=None, labelpad=None, *,
273271
iflabelpadisnotNone:
274272
self.yaxis.labelpad=labelpad
275273
_protected_kw= ['y','horizontalalignment','ha']
276-
ifany([kinkwargsforkin_protected_kw]):
274+
if{*kwargs}& {*_protected_kw}:
277275
iflocisnotNone:
278-
raiseTypeError('Specifying*loc* is disallowed when any of'
279-
'its corresponding low level kwargs{} '
280-
'are supplied as well.'.format(_protected_kw))
276+
raiseTypeError(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=lociflocisnotNoneelsercParams['yaxis.labellocation']
284282
cbook._check_in_list(('bottom','center','top'),loc=loc)
285-
ifloc=='top':
286-
kwargs['y']=1.
287-
kwargs['horizontalalignment']='right'
288-
elifloc=='bottom':
289-
kwargs['y']=0.
290-
kwargs['horizontalalignment']='left'
283+
ifloc=='bottom':
284+
kwargs.update(y=0,horizontalalignment='left')
285+
elifloc=='top':
286+
kwargs.update(y=1,horizontalalignment='right')
291287
returnself.yaxis.set_label_text(ylabel,fontdict,**kwargs)
292288

293289
defget_legend_handles_labels(self,legend_handler_map=None):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp