matplotlib quiver 3d error
Question: I am running the quiver3d example given in the following tutorial
<http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html>

I am running python 'Python 2.7.6' on mac Yosemite with matplotlib 1.4.2

    
    
    Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import matplotlib
    >>> matplotlib.__version__
    '1.4.2'
    

I am running the example given in matplotlib tutorial

    
    
    from mpl_toolkits.mplot3d import axes3d
    import matplotlib.pyplot as plt
    import numpy as np
    
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    x, y, z = np.meshgrid(np.arange(-0.8, 1, 0.2),
                          np.arange(-0.8, 1, 0.2),
                          np.arange(-0.8, 1, 0.8))
    
    u = np.sin(np.pi * x) * np.cos(np.pi * y) * np.cos(np.pi * z)
    v = -np.cos(np.pi * x) * np.sin(np.pi * y) * np.cos(np.pi * z)
    w = (np.sqrt(2.0 / 3.0) * np.cos(np.pi * x) * np.cos(np.pi * y) *  np.sin(np.pi * z))
    
    ax.quiver(x, y, z, u, v, w, length=0.1)
    
    plt.show()
    

but getting the following error

    
    
    Traceback (most recent call last):
      File "try.py", line 16, in <module>
        ax.quiver(x, y, z, u, v, w, length=0.1)
      File "/Library/Python/2.7/site-packages/matplotlib/axes/_axes.py", line 4179, in quiver
        q = mquiver.Quiver(self, *args, **kw)
      File "/Library/Python/2.7/site-packages/matplotlib/quiver.py", line 417, in __init__
        X, Y, U, V, C = _parse_args(*args)
      File "/Library/Python/2.7/site-packages/matplotlib/quiver.py", line 379, in _parse_args
        nr, nc = U.shape
    ValueError: too many values to unpack
    

BTW ax is an Axes3D I verified it using `isinstance(ax, axes3d.Axes3d)` and it
returned True. Plus I verified if Axes3d definition contains quiver method and
apparently it doesn't and it is using Axes quiver method instead. Now I don't
know if it must have quiver definition or not


Answer: `ax` needs to be an `axes3d` object - at the moment it's just a regular `axes`
object, and so the call to `ax.quiver` is calling the 2D routine, which has a
different function signature. If you look at those lines in the source you'll
see that line 417 of `/Library/Python/2.7/site-packages/matplotlib/quiver.py`
is trying to unpack all of your arguments, `x,y,z,u,v,w` \- 6 args, into just
5 variables.

I'm not sure why, and can't check at the moment, but for some reason
`fig.gca(projection="3d")` is _not_ giving you an `axes3d` object, and so the
2D version of quiver is being caleld instead of the 3D one.

Doing a little more digging, `fig.gca(...)` just calls
`fig.add_subplot(1,1,1,**kwargs)` if there's no axes object on the stack. Is
this a complete program? or are you doing this after doing some other stuff in
the same program?

You could try replacing the `gca` call with
`add_subplot(1,1,1,projection='3d')` \- that does not query the stack, so it
won't matter if you have other stuff there already.

