Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pcolor() not using "data" keyword argument #7015

Closed
Lunderberg opened this issue Sep 1, 2016 · 1 comment
Closed

pcolor() not using "data" keyword argument #7015

Lunderberg opened this issue Sep 1, 2016 · 1 comment

Comments

@Lunderberg
Copy link

The data keyword argument when calling pcolor cannot be used to pass the xy-coordinates and bin values. From the online documentation, the data keyword should be able to replace "any positional or keyword argument" in pcolor. This issue is demonstrated in the following script.

#!/usr/bin/env python3

import matplotlib.pyplot as plt
import numpy as np

X = np.array([1,2,3,4,5,6])
Y = np.array([1,2,3,4,5,6])
C = np.array([[1,2,3,4,5],
              [2,3,4,5,6],
              [3,4,5,6,7],
              [4,5,6,7,8],
              [5,6,7,8,9]])

plt.pcolor(X, Y, C)
plt.show()

plt.pcolor(data = {'X':X, 'Y':Y, 'C':C})
plt.show()

Expected behavior: The same plot is displayed twice.
Actual behavior: The first call to pcolor produces the expected plot, but the second call to pcolor gives a TypeError with the following traceback.

Traceback (most recent call last):
  File "./example.py", line 17, in <module>
    plt.pcolor(data = {'X':X, 'Y':Y, 'C':C})
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 3018, in pcolor
    ret = ax.pcolor(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/axes/_axes.py", line 4890, in pcolor
    X, Y, C = self._pcolorargs('pcolor', *args, allmatch=False)
  File "/usr/lib/python3/dist-packages/matplotlib/axes/_axes.py", line 4696, in _pcolorargs
    'Illegal arguments to %s; see help(%s)' % (funcname, funcname))
TypeError: Illegal arguments to pcolor; see help(pcolor)

This was tested using Matplotlib v1.4.2 running on Debian 8 (Jessie). Identical results were obtained on both python 2.7.9 and python 3.4.2. Python and matplotlib were installed from apt-get, using the "python", "python-matplotlib", "python3" and "python3-matplotlib" packages.

@efiring
Copy link
Member

efiring commented Sep 1, 2016

Support for data was added in the 1.5 series; that's the version documented by the web link you gave. You can uninstall the Debian matplotlib packages and then use "pip install matplotlib" to get a v1.5.x version.

@efiring efiring closed this as completed Sep 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants