Message Boards Message Boards

0
|
1491 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Manually plot vector with ListVectorPlot

Posted 1 year ago

Hello everyone,

I was wondering if there is a way to manually plot vectors according to its position (xi, yi) and the vector field value (vxi, vyi). The function ListVectorPlot does it but it does not allow a complete manual plot. For instance, it cannot draw a single vector since it interpolates the data to draw the whole vector field, and so a single vector is not enough data to interpolate. This makes no sense to me because if I want a whole vector field, I would use VectorPlot instead of this function. I saw some posts a long time ago about this issue of ListVectorPlot but it seems like it hasn't been fixed.

Anyhow, I tried to plot several vectors on a vertical line and it's not possible because the data is not valid. This is an example that work for ListVectorPlot

   ListVectorPlot[{{{0, 1}, {1, 1}}, {{2, 3}, {1, 2}}, {{0, 2}, {1, 
        1}}}, VectorPoints -> All]

However when I want to plot the vectors on the vertical line. it does not work

ListVectorPlot[{{{2, 1}, {1, 1}}, {{2, 2}, {1, 2}}, {{2, 3}, {1, 
    1}}}, VectorPoints -> All]

And the error is

ListVectorPlot::vfldata: {{{2,1},{1,1}},{{2,2},{1,2}},{{2,3},{1,1}}} is not a valid vector field dataset or a valid list of datasets.

Any suggestion? Thank you so much.

POSTED BY: Phuong Nguyen
3 Replies

With some Mathematica knowledge you can do whatever:

Graphics[
 Map[{Thickness[RandomReal[{.001, .05}]], 
    Arrowheads[(#[[1, 1]] + #[[2, 2]])/10], RandomColor[], 
    Arrow[{#[[1]], #[[1]] + #[[2]]}]} &, {{{0, 1}, {1, 1}}, {{2, 
     3}, {1, 2}}, {{0, 2}, {1, 1}}}], Frame -> True]
POSTED BY: Gianluca Gorni

You can use graphic primitives:

Graphics[
 Map[Arrow[{#[[1]], #[[1]] + #[[2]]}] &, {{{0, 1}, {1, 1}}, {{2, 
     3}, {1, 2}}, {{0, 2}, {1, 1}}}], Frame -> True]
POSTED BY: Gianluca Gorni
Posted 1 year ago

Thanks for the suggestion Gianluca,

I guess that then there is no way to use the ListVectorPlot, because with the Graphic function, it will be quite annoying to format the graph, e.g. color, style of each vector (at least with my Mathematica knowledge).

POSTED BY: Phuong Nguyen
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