# How can I let the length of a vector in VectorPlot be represented by it´s norm?

I would like to draw a vector field and let the magnitude of the vectors change over time (t) using the Manipulate function. The direction of the vectors will be static.

Manipulate[
VectorPlot[{Cos[t]*(-y), Cos[t]*x}, {x, -1, 1}, {y, -1, 1}]
, {t, 0, 2 Pi}]


You can see that Cos[t] is the factor i use to scale the vectors. By default the plotted vectors all have the same length and a color function is used to indicate magnitude. However, i would like to have the magnitude represented by the length of the vectors, not by color. If i use VectorScaling, the vectors are scaled independently for every frame so if i play the animation there will be no change visible until the orientation switches. I would like to see the length of the vectors change over time. Is there an easy way to do this?

Any help will be greatly appreciated.

Greetings,

Fabian.

• What version are you using? See VectorScale and follow the links if you're using V12.1 or later. (VectorPlot was changed significantly, so the version is important.) Commented Nov 26, 2020 at 16:55

For version V12.1. I couldn't figure out a way to get VectorScaling to do anything except the limited options listed in the docs. (The old VectorScale seemed simultaneously more versatile and inscrutable.)

interp[p_, q_, s_] := ( p (1 - s) + q (1 + s))/2;
Manipulate[
VectorPlot[{Cos[t]*(-y), Cos[t]*x}, {x, -1, 1}, {y, -1, 1},
VectorScaling -> Automatic] /.
Arrow[{p_, q_}] :>
Arrow[{interp[p, q, -Abs@Cos[t]], interp[p, q, Abs[Cos[t]]]}],
{t, 0, 2 Pi}]


Note that the rescaling by VectorPlot still makes the scaling by Cos[t] irrelevant, except for the sign of Cos[t]. One could omit the Cos[t] from the vector field and the Abs from the interpolation and get the same plot.

• Thank you so much for your help! Commented Nov 26, 2020 at 18:06