0
$\begingroup$

I am trying to make a vector plot (3D or 2D) of the following list of 3 vectors. I simply failed to comprehend why I keep getting an error. Neither ListVectorPlot3D nor ListvectorPlot works.

Table[P2[[All, m, n]], {m, 1, 5}, {n, 1, 5}];
Dimensions[%]
ListVectorPlot3D[Table[P2[[All, m, n]], {m, 1, 5}, {n, 1, 5}]]

(* {5, 5, 3} *)

ListVectorPlot3D::vfldata: "{{{-0.686557,-0.686557,0},{-0.670429,-0.705715,0},{-0.652753,-0.725281,0},{-0.633417,-0.745197,0},{-0.612312,-0.76539,0}},<<3>>,{{-0.76539,-0.612312,0},<<3>>,{-0.699795,-0.699795,0}}} is not a valid vector field dataset or a valid list of datasets."

$\endgroup$
2
  • $\begingroup$ What is P2? It will help to diagnose the problem if we know what its values are. $\endgroup$
    – rcollyer
    Jul 1 '13 at 18:24
  • $\begingroup$ Sorry, I should be much more informative. I have an array of 3-vectors on a 41x41 array (denoting the xy plane), creating a {3,41,41} matrix. I need to create a 3d (xyz) map of these vectors. I presume I need ListVector3D. But how do I covert my {3,41,41} to the requisite form? $\endgroup$ Jul 1 '13 at 21:21
1
$\begingroup$

If you use the first form of ListVectorPlot3D then your Dimensions should be {k,m,n,3} - a 3D array of 3D vectors. If you want the second form, then your dimensions should look {...,2,3} - a nD array of pairs of 3D vectors. Your {5,5,3} doesn't match any of these.

d1 = Table[{i, j, k}, {i, 1, 2}, {j, 1, 3}, {k, 1, 4}]; (* first form *)
d2 = Table[{{i, j, k}, {i, j, k}}, {i, 1, 2}, {j, 1, 3}, {k, 1, 4}]; (* second form *)
d3 = Flatten[d2, 2]; (* second form *)
Dimensions /@ {d1, d2, d3}
(* {{2, 3, 4, 3}, {2, 3, 4, 2, 3}, {24, 2, 3}} *)
Row[ ListVectorPlot3D /@ {d1, d2, d3}]

Also you should decide what you are visualizing a 3D field (with ListVectorPlot3D) or a 2D field (with ListVectorPlot).

Since all your points are effectively in one plane you will face the problem mentioned here. ListVectorPlot3D will try to interpolate and fail. You can try to draw a lot of Arrows instead:

arrows = Table[
   Arrow[{{i, j, 0}, {i, j, i + j}}], {i, 1, 10}, {j, 1, 10}];
Graphics3D@arrows
$\endgroup$
2
  • $\begingroup$ Sorry, I should be much more informative. I have an array of 3-vectors on a 41x41 array (denoting the xy plane), creating a {3,41,41} matrix. I need to create a 3d (xyz) map of these vectors. I presume I need ListVector3D. But how do I covert my {3,41,41} to the requisite form? $\endgroup$ Jul 1 '13 at 19:52
  • $\begingroup$ @AnshumanPal, I edited the answer. $\endgroup$
    – BlacKow
    Jul 1 '13 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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