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

Commit557ddea

Browse files
committed
updated fix for#8818
1 parent73101a2 commit557ddea

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,26 @@ def _plot_args_replacer(args, data):
5555
return ["y"]
5656
eliflen(args)==2:
5757
# this can be two cases: x,y or y,c
58+
if (notargs[1]indataand
59+
not (hasattr(data,'dtype')and
60+
hasattr(data.dtype,'names')and
61+
data.dtype.namesisnotNoneand
62+
args[1]indata.dtype.names)):
63+
# this is not in data, so just assume that it is something which
64+
# will not get replaced (color spec or array like).
65+
return ["y","c"]
5866
# it's data, but could be a color code like 'ro' or 'b--'
5967
# -> warn the user in that case...
60-
6168
try:
6269
_process_plot_format(args[1])
6370
exceptValueError:
6471
pass
6572
else:
66-
# arg can be parsed into colour; verify arg is not data
67-
ifnotargs[1]indata:
68-
return ["y","c"]
69-
else:
70-
warnings.warn(
71-
"Second argument {!r} is ambiguous: could be a color spec "
72-
"but is in data; using as data. Either rename the entry "
73-
"in data or use three arguments to plot.".format(args[1]),
74-
RuntimeWarning,stacklevel=3)
75-
73+
warnings.warn(
74+
"Second argument {!r} is ambiguous: could be a color spec but "
75+
"is in data; using as data. Either rename the entry in data "
76+
"or use three arguments to plot.".format(args[1]),
77+
RuntimeWarning,stacklevel=3)
7678
return ["x","y"]
7779
eliflen(args)==3:
7880
return ["x","y","c"]

‎lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ def test_structured_data():
588588
# support for stuctured data
589589
pts=np.array([(1,1), (2,2)],dtype=[("ones",float), ("twos",float)])
590590

591+
# this should not read second name as a format and raise ValueError
591592
fig,ax=plt.subplots(2)
592593
ax[0].plot("ones","twos",data=pts)
593594
ax[1].plot("ones","twos","r",data=pts)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp