Message Boards Message Boards

1
|
7652 Views
|
24 Replies
|
6 Total Likes
View groups...
Share
Share this post:
GROUPS:

How do I plot several (milions) of Arrows?

Posted 11 years ago

Hi,

I have two huge tables of 3D vectors. Now I want to plot Arrows. I tried to do this

For[i = 1, i < 11, i++, 
 Showt[Graphics[
   Arrow[{seznamcek[[i]], Seznam[[i]] + seznamcek[[i]]}]]]]

But it really doesn't work the way I Imagined... (it doesn't work at all). But at least you can see tables: "Seznam" and "seznamcek". Also, additional question: Those two tables are big (but both the same size). Is it possible do define that For should end when it comes to the end of the table?

Thank you, cheers

POSTED BY: Mitja Jan?i?
24 Replies
Posted 11 years ago

"I think that the important point is that the vector field data needs to be given on a regular 3-D array (i.e., a completely filled in rectangular array of positions) of vector values."

Ah ha.

POSTED BY: Gary Palmer

I think that the important point is that the vector field data needs to be given on a regular 3-D array (i.e., a completely filled in rectangular array of positions) of vector values. The documentation says:

"ListVectorPlot3D by default interpolates the data given and plots vectors for the vector field at a regular 3D grid of positions. "

So, in the case of the first example,the values of the positions are assumed and in the second example the values of the positions are specified.

Note also that in your example of

{{{1, 2, 3}, {4, 5, 6}}, {{1, 2, 3}, {3, 2, 4}}, {{1, 2, 3}, {7, 2, 5}}}

you have repeated the point {1,2,3} in each case leading to ambiguity of what the vector field value is at that point.

But the main point in all of this is that the data needs to be specified on a regular cartesian grid with no points left out.

POSTED BY: David Reiss
Posted 11 years ago
POSTED BY: Gary Palmer
POSTED BY: Mitja Jan?i?

The argument to ListVectorPlot3D needs to be a 3 dimensional array of triples. Your example is a 2-dimensional array of triples:

In[1]:= Dimensions[{{{1, 1, 1}, {2, 3, 5}}, {{2, 3, 1}, {6, 3, 1}}}]

Out[1]= {2, 2, 3}

That is, you need to have a triple at each point of a 3-dimensional array.

The examples in the Documentation Center give some examples of this.

POSTED BY: David Reiss

Where can you see examples?

Because my idea was to plot the vector field using VectorListPlot3D to check if the illustration can be any better. :/

POSTED BY: Mitja Jan?i?
Posted 11 years ago

The second example at ref/ListVectorPlot3D shows what appears to be a two-dimensional array of triples, one dimension for the point of origin and one for the vector placed at that point.

POSTED BY: Gary Palmer

Yes, I know, I was looking at this example too, but I still don't understand why this doesn't want to work with my data?

Can you please correct this example? Maybe than the things will be obvious.

ListVectorPlot3D[{{{1, 1, 1}, {2, 3, 5}}, {{2, 3, 1}, {6, 3, 1}}}]
POSTED BY: Mitja Jan?i?

This is the form of your input (where each vec is a possibly different 3-vector):

{{vec, vec}, {vec, vec}}

This is an example of the form that is needed for the special case of only two by two vector values:

Table[vec, {x, 0, 1, 1}, {y, 0, 1, 1}, {z, 0, 1, 1}]

gives

{{{vec, vec}, {vec, vec}}, {{vec, vec}, {vec, vec}}}

Note that above each {{vec,vec},{vec,vec}} is a 2x2 planar set of 3-vectors (the first in the x-y plane at z=0the second in parallel to the x-y plane at z=1.

Note that your example will not work if we just put an additional set of list brackets around it since is would only comprise vector field values in a single plane and so the interpolation will have nothing to work with in the 3rd dimension. But this contrived example does work (it replicates your data twice in the z-direction):

ListVectorPlot3D[{{{{1, 1, 1}, {2, 3, 5}}, {{2, 3, 1}, {6, 3, 1}}}, {{{1, 1, 
     1}, {2, 3, 5}}, {{2, 3, 1}, {6, 3, 1}}}}]
POSTED BY: David Reiss

You see, that's so confusing. Why does it have to be so complicated? I highly regret never learning Mathematica. Now that this is clear, I have no idea how to correct my data in Mathematica :/

Table[vec, {x, 0, 1, 1}, {y, 0, 1, 1}, {z, 0, 1, 1}]

What are those x,y,z? Is that {x, xmin, xmax, step} ? If yes, ok, But how do I create the same table with the data I already have? :(

POSTED BY: Mitja Jan?i?

The x, y and z are just iteration variables to construct the Table in the example for illustrative purposes..

http://reference.wolfram.com/language/ref/Table.html

I agree that the needs of the input for ListVectorPlot3D are a bit confusing. But think of needing to create a grid (a 3 dimensional array) of things, each such thing which is a vector.

POSTED BY: David Reiss

Apply Dimensions to the array to see its structure.

First example at ref/ListVectorPlot3D

In[73]:= Dimensions[
 Table[{x, y, z}, {x, -1, 1, .1}, {y, -1, 1, .1}, {z, -1, 1, .1}]]

Out[73]= {21, 21, 21, 3}

Second example there:

In[74]:= Dimensions[
 Table[{{x, y, z}, {y, x - x^3, z}}, {x, -1.5, 1.5, 0.2}, {y, -2, 2, 
   0.2}, {z, -1, 1, 0.1}]]

Out[74]= {16, 21, 21, 2, 3}
POSTED BY: David Reiss

I don't get it...

In[102]:= tocke[[1]]

Out[102]= {-100, -100, -100}

In[103]:= Dimensions[tocke[[1]]]

Out[103]= {3}

In[104]:= polje[[1]]

Out[104]= {-5.49968*10^-18, 1.60511*10^-11, -1.60511*10^-11}

In[105]:= Dimensions[polje[[1]]]

Out[105]= {3}

In[106]:= Dimensions[{tocke[[1]], tocke[[1]] + polje[[1]]}]

Out[106]= {2, 3}

Maybe I understand word "Dimension" a lot different than I should or maybe I am sitting behind a computer for too long today.

POSTED BY: Mitja Jan?i?
In[110]:= Dimensions[{tocke[[1]], tocke[[1]] + polje[[1]], {1, 1, 1}}]

Out[110]= {3, 3}

But I don't have the third vector {1,1,1} O.o

POSTED BY: Mitja Jan?i?
Posted 11 years ago

I copied the second data structure shown in the attachment and I added one additional tuplet of vectors to replace the ellipsis. I replaced the symbols with numbers, getting

{{{1, 2, 3}, {4, 5, 6}}, {{1, 2, 3}, {3, 2, 4}}, {{1, 2, 3}, {7, 2, 5}}}

When I applied ListVectorPlot3D to this I got the error message

“… {{{1.,2.,3.},{4.,5.,6.}},{{1.,2.,3.},{3.,2.,4.}},{{1.,2.,3.},{7.,2.,5.}}} is not a valid vector field dataset or a valid list of datasets. “

I applied Dimensions to the data structure, getting:

 {3, 2, 3}

which appears to show three instances of two triplets each. Thus, it should plot 3 vectors. DoesnÂ’t this show there is something either wrong or incomplete in the template from the documentation? Or are we still having a conceptual difficulty?

I am using Mathematica 10.

Attachments:
POSTED BY: Gary Palmer
Attachments:
POSTED BY: Mitja Jan?i?

For, Do, and similar constructs do not return an output.

http://reference.wolfram.com/language/ref/For.html

With regard to using Show in this, you may want to just construct the list of graphics primitives (the Arrows) and then wrap Graphics around it. For example something like this (but I don't have your data so I do not know if your seznamcek and Seznam are set up correctly):

Graphics[
Table[
  Arrow[{seznamcek[[i]], Seznam[[i]] + seznamcek[[i]]}], {i, 1, 11}]
]

Also I suggest you graduate from doing this sort of thing procedurally and to it functionally as in the above example.

I hope this helps.

POSTED BY: David Reiss
Posted 11 years ago

Make sure that seznamcek[[i]] and the following point both have the structure of a vector, that is, the argument to Arrow has the structure

 {{a, b,}, {c, d}} or {{a, b, c}, {d, e, f}}.

Even so, For seems to suppress the Graphics output. I don't know why. Try something like this:

t = Table[Arrow[{{1, 4}, {6, x}}], {x, 1, 10}];

Graphics[t]

If you want the arrows to appear sequentially, use Manipulate or Animate.

POSTED BY: Gary Palmer

Are you able to use ListVectorPlot3D? It seems to automatically draw arrows too.

POSTED BY: Isaac Abraham

Even than, it doesn't work.

POSTED BY: Mitja Jan?i?
Posted 11 years ago

When I run it, I see the error message "Part::partd: Part specification seznamcek[[1]] is longer than depth of object. >>", suggesting that seznamcek is empty or hasn't been defined. It's hard to say more without seeing more of your program.

POSTED BY: Gary Palmer
Posted 11 years ago
POSTED BY: Gary Palmer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract