Home > OS >  3d quiver plot from .npy data files to give a 3d vector field
3d quiver plot from .npy data files to give a 3d vector field

Time:05-13

I want to plot a 3d velocity vector field using a 3d quiver plot in python, from 3 data files (.npy) that give u, v and w components of velocity in the x, y and z directions. This what I have done so far, showing the error message as well. How do I create a 3d quiver plot from three 3d .npy data files? I have also looked at other examples enter image description here

CodePudding user response:

Based on the above comment, to create a 3D quiver plot X1, Y1, Z1, U, V, W must have the same shape.

Try to modify the following lines of code:

import numpy as np
nx, ny, nz = 160, 284, 160

x1 = range(nx)
y1 = range(ny)
z1 = range(nz)

X1, Y1, Z1 = np.meshgrid(x1, y1, z1)

Note that I changed nx, ny, nz = 284, 160, 160 to nx, ny, nz = 160, 284, 160. This should give X1, Y1, Z1 the correct shape.

CodePudding user response:

I found the following code produced a 3d quiver plot from 3 data files (3d arrrays in .npy files). The code was adapted from enter image description here

  • Related