5
$\begingroup$

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.

$\endgroup$
6
  • 1
    $\begingroup$ Can you upload a sample of you data please? $\endgroup$ Jun 6 '13 at 1:46
  • $\begingroup$ Ok, here is a sample: link $\endgroup$
    – PerroNoob
    Jun 6 '13 at 2:02
  • $\begingroup$ How very odd... all your data points lie in a plane? $\endgroup$ Jun 6 '13 at 2:28
  • $\begingroup$ Yes, it's a 2D plane and I wanted 3D vectors, so I put z=0 for all the vectors $\endgroup$
    – PerroNoob
    Jun 6 '13 at 2:30
  • $\begingroup$ This is a bit weird David. I don't have time to poke around much more - I'm sure someone here knows what's happening there $\endgroup$ Jun 6 '13 at 2:34
8
$\begingroup$

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}]

3D plot of vectors

2D ListVectorPlot:

ListVectorPlot[Map[Most, vecdata, {2}]]

2D ListVectorPlot

$\endgroup$
2
  • $\begingroup$ Thanks! I've learned a lot with your answer. When I plot with all my data, the box is too small in height. Is there a way to get a larger box in Graphics3D? $\endgroup$
    – PerroNoob
    Jun 6 '13 at 3:29
  • 2
    $\begingroup$ @DavidWinchester Set BoxRatios -> {1,1,1} or whatever relative sizes you want. Thank you, too. $\endgroup$
    – Michael E2
    Jun 6 '13 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.