# plotting a 3d vector field from a list

I have imported data to a list as below.

nn = Import["df.dat", "Table"];


nn is a 100 by 4 matrix which shows a 3D director field in 100 different points in x-y plane (the vectors are 3d, but their origins are in a 2D plane). To be more clear, $$nn[[3, i]]$$ shows the component of the vector originated at point 3 in the space. $$i=1,2,3$$ show the x,y,z component of the vector and i=4 shows the length of the vector.

Also, these 100 points in the 2D plane are arranged on a 10 by 10 square with equal distance.

I really appreciate it if someone can help me to visualize this vector field in an appropriate way.

Below is the first 5 lines of the df.dat file.

0.121963 -0.224769 0.966749 0.340097
0.095170 -0.243081 0.965326 0.340081
0.068667 -0.261505 0.962756 0.340071
0.042826 -0.279722 0.959125 0.340065
0.017990 -0.297426 0.954575 0.340059


The first line corresponds to the point (x,y)=(0,0), the second point to the point (x,y)=(1,0) and so on. The 12th point corresponds to (x,y)=(2,1), the 14th point to (x,y)=(3,1) and so on.

• Please give a minimal example of your df.dat. Dec 20, 2020 at 11:48
• did you see this? mathematica.stackexchange.com/a/26523/1089 Dec 20, 2020 at 11:49
• @cvgmt I don't know how to upload it here. Dec 20, 2020 at 12:07
• Just post some part of your data as code. Dec 20, 2020 at 12:12
• added now. @cvgmt Dec 20, 2020 at 12:15

An example, that assumes that the vectors on the grid are numbered from 1 to 100:

vecs = Table[{1, 1, 1} i/10, {i, 100}];
origins = Flatten[Table[{i, j, 0}, {i, 10}, {j, 10}], 1];
Graphics3D[Table[Arrow[{t = origins[[i]], t + vecs[[i]]}], {i, 100}]] • Could you please use the matrix nn with its 4 columns in your answer so that it becomes clear how your answer is related to the question? Dec 20, 2020 at 12:10
• If I understood your description right, then the 3 first columns give the vector and the fourth its length. In this case the fourth is superfluous because the length is already specified implicitly by the 3 first columns. Dec 20, 2020 at 12:13
• It is true. Could you please use the matrix nn in your answer? It is not clear how your solution matches with nn with its first 3 colomns and 100 rows. Dec 20, 2020 at 12:26
• The vectors are numbered: 1..10 for origins {x,y}={1,1}..{1,10}, 11..20 for origins {2,1}.{2,10} e.t.c Dec 20, 2020 at 12:29
• I am confused by your solution. I don't see how it is related to the question as I do not see any nn matrix in your solution. Dec 20, 2020 at 12:32