Message Boards Message Boards

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

How do I plot several (milions) of Arrows?

Posted 10 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 10 years ago

Show is misspelled as Showt.

POSTED BY: Gary Palmer

Even than, it doesn't work.

POSTED BY: Mitja Jan?i?

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

POSTED BY: Isaac Abraham
Posted 10 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 10 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

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

I just wonder what several million arrows on a typical window size plot would look like? If they are more or less evenly distributed on the domain you are just going to get a black plot. Otherwise you are going to get clumpy smears. It will probably need a better treatment than just plotting all the arrows - unless you have some super large display with extra fine detail. What do you expect the field to look like?

One technique might be to select a few hundred arrows at random and try multiple samples.

If there are critical regions you may have to zoom in on them.

One surprisingly effective technique is to generate an Interpolation function (if you can) and plot only a single arrow! But attach it to a movable Locator that you can drag around to explore the field.

Ok firstly, thanks to everybody fur such a great help. I was able to plot those 9621 Arrows. :)

Secondly, To David J M Park Jr.:

Hmm, to be honest with you at first I wasn't really happy with your answer, but after plotting those 9621 Arrows in a 202020 window it got Immediately obvious what you are trying to say. If I was able to get an analytic solution this everything would never be my problem (I would simply use stream plot or something), but to get analytic solution is more or less impossible, so I got some numerical values and now I want to plot this vector field. Of course, I want to plot it so that I can actually see some things...

Both of your options sound really awesome to me and make me wonder how can I do that? :) Maybe it is possible to correct the code of another David (above your post)? I would like to generate an interpolation but I am afraid that's a bit too much for my knowledge of mathematica. :/

Most of you wanted to have the data: Now it is attached.

Attachments:
POSTED BY: Mitja Jan?i?

One more thing:

Why doesn't this work?:

ListVectorPlot3D[{{{1, 1, 1}, {2, 3, 5}}, {{2, 3, 1}, {6, 3, 1}}}]

Visualization`Core`ListVectorPlot3D::vfldata: {{{1.,1.,1.},{2.,3.,5.}},{{2.,3.,1.},{6.,3.,1.}}} is not a valid vector field dataset or a valid list of datasets.
POSTED BY: Mitja Jan?i?
Posted 10 years ago

I would also like to know the answer. It appears to match the format for a "3d vector plot from vector field values {vx1, vy1, vz1} given at specified points {x1, y1, z1}" (from ?ListVectorPlot3D).

POSTED BY: Gary Palmer

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 10 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?

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?

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
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?

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?
Posted 10 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

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

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
Posted 10 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
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