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'm trying to make an animation of a time-varying 2D vector field. However, I'm got a difficulty in that Mathematica normalises the length of the vectors with each call to VectorPlot.

A (very simple) example:

myField = {Cos[2 π t], 0};

        VectorPlot[myField /. t -> TT, {x, -1, 1}, {y, -1, 1}],
        {TT, 0, 1}]

Expected result: The arrows grow and shrink in time

The actual result: The arrows remain the same size, but flick direction

Is there some way to fix the length of the arrows relative to the field value?

share|improve this question
You've seen VectorScale? – J. M. Jun 11 '13 at 13:35
up vote 6 down vote accepted

As @Ox4A4D mentioned in the comment, you could use the option VectorScale to set the length of vectors, here is an example code:

myField = {Cos[2 \[Pi] t], 0};
Animate[VectorPlot[myField /. t -> TT, {x, -1, 1}, {y, -1, 1}, 
          VectorScale -> Abs[0.05 Cos[2 Pi TT]]], {TT, 0, 1}]
share|improve this answer
Ah, I see -- it's making use of the fact that you know what the maximum value is with this simple function. Perhaps that will put me on the right track... – Eoin Jun 11 '13 at 15:04

With a slightly more interesting function, and cleaner syntax:

myField[x_, y_, t_] := {Cos[2 Pi x t], Sin[2 Pi y t]};

Animate[VectorPlot[myField[x, y, t], {x, -1, 1}, {y, -1, 1}, 
  VectorScale -> {Small, 1, None}], {t, 0, 1}]

Check the documentation and play around with the arguments to VectorScale as required.


I had indeed misunderstood your requirements. mm.Jang's answer is what you're looking for. 0.05*Norm[myField[t]] should generalize it.

share|improve this answer
Your code somehow doesn't work for me... I'm using MMA by the way... – Rod Jun 11 '13 at 13:53
Any error? I'm on on 64-bit Linux. – Corey Kelly Jun 11 '13 at 13:59
@RodLm you must run Clear[myField]; first. – mm.Jang Jun 11 '13 at 14:00
@CoreyKelly Yes, when I run your code nothing happens. I mean, the slider t moves itself but no vector plot is shown. – Rod Jun 11 '13 at 14:00
@mm.Jang Thank you... problem solved! Corey, please forget what I've written before. – Rod Jun 11 '13 at 14:02

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.