I have a vector field:
...but when I want to plot the associated streamplot, I get an error:
ValueError: The rows of 'x' must be equal
Here is my code:
import matplotlib.pyplot as plt
import numpy as np
NY = 20; ymin = -2.; ymax = 2.
dy = (ymax -ymin )/(NY-1.)
NX = NY
xmin = -2.; xmax = 2.
dx = (xmax -xmin)/(NX-1.)
y = np.array([ ymin + float(i)*dy for i in range(NY)])
x = np.array([ xmin + float(i)*dx for i in range(NX)])
x, y = np.meshgrid( x, y, indexing = 'ij', sparse = False)
Fx = np.cos(x + 2*y)
Fy = np.sin(x - 2*y)
F = np.array([Fx, Fy])
# plotting the vectors
plt.quiver(x,y,Fx,Fy)
# Plotting stream plot
plt.streamplot(x, y, Fx, Fy)
plt.show()
Anyone knows why? I have checked the sizes, but they seem equal to me...
Edit:
From the comment section by Trenton McKinney:
" Note xx and yy in this answer. Each row is the same, but the values in each row are increasing. The values in each of your rows are the same, but each row is increasing. "
... I tried:
plt.streamplot(np.transpose(x), np.transpose(y), Fx, Fy)
but as you can see the streamplot is not correct.


