Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb20640

Browse files
committed
updated fix for #8818
1 parent 73101a2 commit fb20640

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ def _plot_args_replacer(args, data):
5555
return ["y"]
5656
elif len(args) == 2:
5757
# this can be two cases: x,y or y,c
58+
if (not args[1] in data and
59+
not (hasattr(data, 'dtype') and
60+
hasattr(data.dtype, 'names') and
61+
data.dtype.names is not None and
62+
args[1] in data.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...
6068

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)