Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Quiver crashes if given matrices #1546

wants to merge 1 commit into from

3 participants


As it is now, quiver() fails if you give it numpy.matrix objects, as this simple example shows:

>>> quiver(np.matrix(np.ones((32, 32))), np.matrix(np.ones((32, 32))))

It does so because it runs ravel() on the input, which if the input is a matrix gives a row matrix of shape (N, 1), instead of an array of shape (N,), which is what quiver expects in further calculations.

This pull request fixes this problem by running the input through np.asarray() before ravel() is called.


I see, yeah that's a problem. The function looked promising here, but it actually just converts a matrix into a masked matrix.

It's hard to realize what the problem is if you happen to do this though, so it would be great if we could spare the people who accidentally do this some headache, in any way possible. Should I just open up an issue?


You could open an issue. Unless other developers think we should put in extensive matrix trapping, the solution would be to put clear "matrix inputs are not supported and may cause hard-to-diagnose errors" warnings in the documentation.

Thank you for pointing out the problem and proposing a solution, but I am going to close this pull request.

@efiring efiring closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 30, 2012
  1. @gustavla
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/matplotlib/
4 lib/matplotlib/
@@ -459,8 +459,8 @@ def draw(self, renderer):
collections.PolyCollection.draw(self, renderer)
def set_UVC(self, U, V, C=None):
- U = ma.masked_invalid(U, copy=False).ravel()
- V = ma.masked_invalid(V, copy=False).ravel()
+ U = ma.masked_invalid(np.asarray(U), copy=False).ravel()
+ V = ma.masked_invalid(np.asarray(V), copy=False).ravel()
mask = ma.mask_or(U.mask, V.mask, copy=False, shrink=True)
if C is not None:
C = ma.masked_invalid(C, copy=False).ravel()
Something went wrong with that request. Please try again.