1
$\begingroup$

I am trying to visualize a complex vector field. However, I seem to have difficulty with the usage of ListVectorPlot3D. The following example works in two dimension, but not in 3D.

I define three points and three vectors:

phasePRange = {{0., 1.}, {-2.5, 2.5}, {-2.5, 2.5}};
phaseBRatios = {1., 2.5, 2.5};

myps = 
  {{0.6317509602269538, 0., 0.}, 
   {0.6315222309581698, -0.49206031006953616, 0.8084147318366528}, 
   {0.6309571144534679, -0.3287921492246488, 1.4140959092626375}};

myvs = 
  {{-6.627612561711319*^-11, -0.5525297131274786, 0.8334932009988242}, 
   {-0.0005729018280423939, -0.39025963088261206, 0.9207046715895726}, 
   {-0.0005483923990602963, 0.884592445730268, 0.46636456149960553}};

and I can display them using the Arrow command:

Graphics3D[
  {{Black, PointSize[.03], Point[myps[[1]]]},
   {Black, PointSize[.03], Point[myps[[2]]]}, 
   {Black, PointSize[.03], Point[myps[[3]]]}, 
   {Thick,Arrowheads[0.03],
     {Blue, Arrow[{myps[[1]], myps[[1]] + myvs[[1]]}]}, 
     {Red, Arrow[{myps[[2]], myps[[2]] + myvs[[1]]}]}, 
     {Green, Arrow[{myps[[3]], myps[[3]] + myvs[[3]]}]}}},
  Axes -> True,
  Boxed -> True,
  BoxRatios -> phaseBRatios, 
  PlotRange -> phasePRange]

enter image description here

However, when I evaluate

myfield = Transpose[{myps, myvs}]
ListVectorPlot3D[myfield,
   VectorPoints -> All,
   VectorScale -> {1., Scaled[.1]}, 
   BoxRatios -> phaseBRatios, 
   AxesLabel -> {"ϵ","u","y"},
   PlotRange -> phasePRange]

I get an empty box with no arrows.

I woudl apprecaite any help to figure out my mistake.

$\endgroup$
  • $\begingroup$ Thank you very much for improving my post layout. $\endgroup$ – I. Konuk Nov 16 '16 at 20:02
1
$\begingroup$

The problem is with the data. ListVectorPlot3D is a variation of VectorPlot3D that attempts to interpolate the data you supply to reproduce the underlying function. If it can't interpolate, it will not draw anything or produce an error. The documentation says:

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

Also, the format for ListVectorPlot3D comes in two flavors (see here). You need to make sure you are either providing pairs of points/vectors sufficient for interpolation, or you are giving an array of vectors.

As a thought experiment, think about this in 2D. You need to provide at least 3 data points for the interpolation to work. So, if you want to have a field of straight vectors and you try to do it by simply doing

ListVectorPlot[{{{0, 0}, {1, 1}}, {{1, 1}, {1, 1}}}]

it wouldn't work -- can't interpolate with two points. So, you need to add a third point, like this:

ListVectorPlot[{{{0, 0}, {1, 1}}, {{.5, .5}, {1, 1}}, {{1, 1}, {1, 1}}}]

The same is true about 3D. You have to provide enough data points so that they can be interpolated.

Read more about it here.

$\endgroup$
  • $\begingroup$ Thank you Stitch very much. Very helpful. This resolves my immediate issue. I wonder why it does not give an error? I tried the following test with different nu2 values. It works with all values nu2=>2. For nu2=1 it gives an error: $\endgroup$ – I. Konuk Nov 18 '16 at 20:44
  • $\begingroup$ <br/> I tried the following test with different nu2 values. It works with all values nu2=>2. For nu2=1 it gives an error: <br/>"VisualizationCoreListVectorPlot3D::vfldata: {{{{{1.,1.,1.},{1.,0.,0.5}}}}} is not a valid vector field dataset or a valid list of datasets."<br/><pre>wind2 = Table[{{i, j, z}, {i, -j, -z}}, {i, 1, nu2}, {j, 1, nu2}, {z, 1, nu2}]; <code><br/><pre>ListVectorPlot3D[wind2, VectorColorFunction -> "DeepSeaColors"]<code> $\endgroup$ – I. Konuk Nov 18 '16 at 20:50
  • $\begingroup$ @I.Konuk When you have nu2=1, you have only one point -- the format is {{point},{vector}}, so there is nothing to plot. My understanding is that it doesn't produce an error when the structure of an array is consistent, but it can't interpolate. $\endgroup$ – Stitch Nov 18 '16 at 22:52

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.