# Vector color function varying upon vector direction

I have the following code:

f[l_, p_, r_, \[Phi]_] := (r Sqrt)^Abs[l] E^(-r^2) LaguerreL[p, Abs[l],2r^2] E^(-I r^2/2) E^(I l \[Phi]);
L[oam1_, r_, \[Phi]_] := f[oam1, 0, r, \[Phi]] {1, I}/Sqrt;
R[oam2_, r_, \[Phi]_] := f[oam2, 0, r, \[Phi]] {1, -I}/Sqrt;
cl = 1/Sqrt;
cr = 1/Sqrt;(*1/Sqrt*)
state[oam1_, \[Theta]_, oam2_, r_, \[Phi]_] := cr*R[oam1, r, \[Phi]] + E^(I \[Theta]) cl*L[oam2, r, \[Phi]];
vvpol = VectorPlot[Evaluate@Re[state[7, Pi, -7, Sqrt[x^2 + y^2], ArcTan[x, y]]], {x, -1.4,1.4}, {y, -1.4, 1.4},RegionFunction -> Function[{x, y, z}, 0.2 < x^2 + y^2 < 1.6],
VectorColorFunction -> (Hue[ArcTan[#, #2]/(2 \[Pi])] &), VectorColorFunctionScaling -> False,
Mesh -> None, PlotRange -> All, ImageSize -> 400, Frame -> True, VectorScale -> {0.03, 0.95, None}, VectorStyle -> {{Thickness[0.007], Black}}, VectorPoints -> 25]


Which produces the following image: As you can see the Hue map varies circularly, independently on the vector directions. What I want to have is a Hue map that varies depending on the direction of the field.

For instance, all the arrows pointing north will be green and all those pointing south blue and, of course, different color shades from north to south and vice-versa.

Can someone help me?

VectorColorFunction >> Details: So we can use

VectorColorFunction -> (Quiet @ Hue[ArcTan[#3, #4]/(2 π)] &)


to get • t is indeed working, thank you! Could you help me to understand it better? I don't think I got the difference between (#,#2) and (#3,#4). What are they precisely doing? Aug 28, 2020 at 12:27
• maybe writing the pure function func = Hue[ArcTan[#3, #4]/(2 π)] & as func[x_,y_,vx_,vy_, norm_]:= Hue[ArcTan[vx, vy]/(2 π)] helps?
– kglr
Aug 28, 2020 at 13:13
• Ah ok, got it! So #3 and #4 states we use the values of the field (vx, vy) in the arctan. Perfect! Thank you to make it clearer :) Aug 31, 2020 at 7:47