diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 74c28306c3a7..7308835fda2d 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -55,7 +55,11 @@ def _plot_args_replacer(args, data): return ["y"] elif len(args) == 2: # this can be two cases: x,y or y,c - if not args[1] in data: + if (not args[1] in data and + not (hasattr(data, 'dtype') and + hasattr(data.dtype, 'names') and + data.dtype.names is not None and + args[1] in data.dtype.names)): # this is not in data, so just assume that it is something which # will not get replaced (color spec or array like). return ["y", "c"] diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index abd2b6675b48..e8cb3a243fde 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -584,6 +584,16 @@ def test_shaped_data(): plt.plot(xdata[:, 1], xdata[1, :], 'o') +def test_structured_data(): + # support for stuctured data + pts = np.array([(1, 1), (2, 2)], dtype=[("ones", float), ("twos", float)]) + + # this should not read second name as a format and raise ValueError + fig, ax = plt.subplots(2) + ax[0].plot("ones", "twos", data=pts) + ax[1].plot("ones", "twos", "r", data=pts) + + @image_comparison(baseline_images=['const_xy']) def test_const_xy(): fig = plt.figure()