How to StreamPlot using existing grid and velocity arrays
How to StreamPlot using existing grid and velocity arrays
I would like to draw a 2D streamline plot in Mathematica based on existing grids, velocity arrays and start points, which were calculated using Matlab/Python code.
The grids are two vectors of size M
and N
containing evenly spaced x_i
and y_j
. The velocity arrays are two M-by-N
matrices containing the gradients dot_x
and dot(y)
at each (x_i,y_j)
of the 2D plane. The start points are a L-by-2
array containing the points streamlines should pass. In python, I would directly call streamplot(x, y, dot_x, dot_y, startpoints=startpoints)
from matplotlib.pyplot
package but this does not give nice figure as Mathematica does.
M
N
x_i
y_j
M-by-N
dot_x
dot(y)
(x_i,y_j)
L-by-2
streamplot(x, y, dot_x, dot_y, startpoints=startpoints)
matplotlib.pyplot
However, the examples I found online are for analytical functions, e.g.,
data = Table[x, y, y, x-x^2, x,-1.5,1.5,0.2, y,-2,2,0.2];
ListStreamPlot[data]
I am new to Mathematica and do not know how to translate the Matlab/Python code to Mathematica. Besides, the code on Matlab is pretty time-consuming so I would rather not run the field functions on Mathematica again.
Is there any way to draw streamline plot using existing arrays? Many thanks.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.