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

Commit5669261

Browse files
authored
Merge pull request#10810 from zhangeugenia/bugfix-for-issue-8818
Fix for plt.plot() does not support structured arrays as data= kwarg
2 parents51c79c8 +557ddea commit5669261

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ def _plot_args_replacer(args, data):
4949
return ["y"]
5050
eliflen(args)==2:
5151
# this can be two cases: x,y or y,c
52-
ifnotargs[1]indata:
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)):
5357
# this is not in data, so just assume that it is something which
5458
# will not get replaced (color spec or array like).
5559
return ["y","c"]

‎lib/matplotlib/tests/test_axes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,16 @@ def test_shaped_data():
584584
plt.plot(xdata[:,1],xdata[1, :],'o')
585585

586586

587+
deftest_structured_data():
588+
# support for stuctured data
589+
pts=np.array([(1,1), (2,2)],dtype=[("ones",float), ("twos",float)])
590+
591+
# this should not read second name as a format and raise ValueError
592+
fig,ax=plt.subplots(2)
593+
ax[0].plot("ones","twos",data=pts)
594+
ax[1].plot("ones","twos","r",data=pts)
595+
596+
587597
@image_comparison(baseline_images=['const_xy'])
588598
deftest_const_xy():
589599
fig=plt.figure()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp