Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was trying to plot a few velocity vectors measured at given points. However I am unable to do this with ListVectorPlot[] function. I get error each time I try to use it (it says: VisualizationCoreListVectorPlot::vfldata: {{{1,1},{2,2}}} is not a valid vector field dataset or a valid list of datasets.). Finally I succeeded using Arrow[] graphics entity, but I'd rather use ListVectorPlot[] function.

Lets say I have three


and 2D vectors measured in that points:


How to prepare data to plot this using ListVectorPlot to get such an image:

Arrows obrained by the following code:

Code used to plot arrows:

ar = {
  Graphics[Arrow[{{1, 1}, {1 + 1, 1 + 0}}]], 
  Graphics[Arrow[{{2, 1}, {2 + 0.7, 1 + 0.1}}]], 
  Graphics[Arrow[{{3, 1}, {3 + 1, 1 - 0.1}}]]
share|improve this question
up vote 4 down vote accepted

Let me explain the error message first. You assumed that you can give a list of points and vectors and ListVectorPlot draws exactly those vectors. This is not the case. If you give ListVectorPlot 4 vectors on the corner of the unit-square, it will do the following:

  {{0, 0}, {1, 1}}, 
  {{1, 0}, {-1, 0}},
  {{1, 1}, {-1, -1}}, 
  {{0, 1}, {-1, 0}}}]

Mathematica graphics

See that it interpolates all values in between? And here is the problem with your dataset. All your vectors lie on a line which makes it impossible to create a 2d-plot.

Therefore, are you sure you want to use ListVectorPlot? What you try can be achieved in one line of code (no matter how many points and vectors you have!)

Graphics[Arrow[{#1, #1 + #2}] & @@@ Transpose[{points, vec}]]

Mathematica graphics

share|improve this answer
Thanks a lot for an explanation. However I can never understand, why such things like Matlab or Mathematica have no functions for plotting vector or scalar fields on FEM or other domains. – Misery Dec 16 '12 at 18:20

The error comes from the fact that all your points lie along a line, while documentation states "ListVectorPlot by default interpolates the data given, and plots vectors for the vector field at a regular grid of positions." I think algorithm cannot produce interpolated 2D field based on 1D data. Let's deviate your data slightly from horizontal line by off-setting vertical coordinate of middle point by 10% up:

points = {{1, 1}, {2, 1 + 0.1}, {3, 1}};
vec = {{1, 0}, {0.7, 0.1}, {1, -0.1}};

Now you can easily produce interpolated vector field:

ListVectorPlot[Transpose[{points, vec}], 
  Epilog -> {Red, PointSize[.03], Point[points]}, 
  VectorColorFunction -> "DeepSeaColors"]

enter image description here

If you wish to see only your given vectors, you need to realize: (1) the vector field by default is generated by passing through the given points, not starting at them, (2) the vector length and arrowhead scales need to be chosen wisely:

ListVectorPlot[Transpose[{points, vec}], 
 VectorPoints -> All, 
 VectorScale -> {1, Scaled[.2]}, 
 Epilog -> {Red, PointSize[.03], Point[points]}] 

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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