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

Commit8fc43eb

Browse files
committed
cleanup _plot_args_replacer logic
1 parent5669261 commit8fc43eb

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

‎lib/matplotlib/axes/_axes.py‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,24 @@
4444
rcParams=matplotlib.rcParams
4545

4646

47+
def_has_item(data,name):
48+
"""Return whether *data* can be item-accessed with *name*.
49+
50+
This supports data with a dict-like interface (`in` checks item
51+
availability) and with numpy.arrays.
52+
"""
53+
try:
54+
returnnameindataornameindata.dtype.names
55+
except (AttributeError,TypeError):
56+
returnFalse
57+
58+
4759
def_plot_args_replacer(args,data):
4860
iflen(args)==1:
4961
return ["y"]
5062
eliflen(args)==2:
5163
# this can be two cases: x,y or y,c
52-
if (notargs[1]indataand
53-
not (hasattr(data,'dtype')and
54-
hasattr(data.dtype,'names')and
55-
data.dtype.namesisnotNoneand
56-
args[1]indata.dtype.names)):
57-
# this is not in data, so just assume that it is something which
58-
# will not get replaced (color spec or array like).
64+
if_has_item(data,args[1]):
5965
return ["y","c"]
6066
# it's data, but could be a color code like 'ro' or 'b--'
6167
# -> warn the user in that case...

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp