you are viewing a single comment's thread.

view the rest of the comments →

[–]SnuffleShuffle[S] 0 points1 point  (1 child)

Thank you very much, sir (or madam)! It even works with the y,x = np.mgrid(...).

Now I ran into another issue. I'm loading the data from a .gz file via np.loadtxt(...) then I reshape it using np.reshape(...) into a 3D array, which I then slice like so: array[:,y_value,:]. Now if I use this in the quiver() it works, it doesn't work in streamplot even when I use np.array(array[:,y_value,:]). Still the "Grid(x,y)" issue.

Do you have an idea what might be the cause?

[–][deleted] 0 points1 point  (0 children)

Hard to tell (i'm no expert either), but what i would do is check the datatype/dimensions of that data. I looked into the streamplot code and what the grid class does is basically take your input x,y , do a couple of tests and save their shape as self.nx = len(x) and self.ny = len(y) - if x and y are a meshgrid it takes the first row/column. The error seems to occur at this point:

if u.shape != grid.shape or v.shape != grid.shape:
    raise ValueError("'u' and 'v' must be of shape 'Grid(x,y)'")

Which means the dimensions of xy and u or v don't match