I have a .dat file with six columns: {x y z vx vy vz}
, where x, y, z are space coordinates and vx, vy, vz are the vector components.
How can I use this file to get a ListVectorPlot3D
image? Because I tried to arrange the data as {{x,y,z}, {vx,vy,vz}}
and Mathematica still gives me an error message:
ListVectorPlot3D::vfldata ... is not a valid vector field dataset or a valid list of datasets.
I haven't found many related question about this, just one about using Graphics
and drawing each vector, but I think it would be simpler to use ListVectorPlot
.
Answer
I imported your data
data = Import["http://pastebin.com/download.php?i=VByC3ZEg", "Table"];
and transformed it into a vector field, deleting duplicated entries:
vecdata = Partition[#, 3] & /@ DeleteDuplicates[data];
As noted in a comment, the base points all lie in the xy-plane (and the z-components of the vectors are nearly the same):
vecdata[[All, 1, 3]] // Union
{0.}
vecdata[[All, 2, 3]] // Union
{-1., -0.998891, -0.995571, -0.990063, -0.982406}
Since the points lie in a plane, ListVectorPlot3D
cannot interpolate a vector field over a region in space and plot it. I can suggest two different visualizations, plotting the vectors themselves (as you considered) and projecting the vectors onto the plane and plotting that field.
The 3D vectors:
Graphics3D[{ColorData[1][1], Arrowheads[Medium], Arrow[{First@#, Total@#}] & /@ vecdata}]
2D ListVectorPlot
:
ListVectorPlot[Map[Most, vecdata, {2}]]
Comments
Post a Comment