Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
1  
Can you upload a sample of you data please? –  Cameron Murray Jun 6 '13 at 1:46
    
Ok, here is a sample: link –  David Winchester Jun 6 '13 at 2:02
    
How very odd... all your data points lie in a plane? –  J. M. Jun 6 '13 at 2:28
    
Yes, it's a 2D plane and I wanted 3D vectors, so I put z=0 for all the vectors –  David Winchester Jun 6 '13 at 2:30
    
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 –  Cameron Murray Jun 6 '13 at 2:34
show 1 more comment

1 Answer

up vote 4 down vote accepted

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

share|improve this answer
    
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? –  David Winchester Jun 6 '13 at 3:29
1  
@DavidWinchester Set BoxRatios -> {1,1,1} or whatever relative sizes you want. Thank you, too. –  Michael E2 Jun 6 '13 at 3:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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