# Color vector according to angle

One can use the function VectorColorFunction in VectorPlot3D to color vectors according to their norms. How to color vectors according to the angle they are pointing along, say, in the x-y plane? Thanks!

VectorPlot3D[{x, y, z}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
VectorColorFunction -> (Hue@Rescale[Arg[#4 + I #5], {0, 2 Pi}] &),
VectorColorFunctionScaling -> False] • Arg[]'s range is $(-\pi,\pi]$. ;) – J. M.'s torpor Nov 5 '15 at 15:17
• @J.M. And the Plots are quite different, I see :) – Dr. belisarius Nov 5 '15 at 15:25

There are a lot of arguments in VectorColorFunction. In your particular case you can write the following

VectorPlot3D[{x, y, z}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
VectorColorFunction ->
Function[{x, y, z, vx, vy, vz, v}, Hue[ArcTan[vx, vy]/2/π]],
VectorColorFunctionScaling -> False] • I was a bit slow... However, I believe this explicit function is more clear for OP. – ybeltukov Nov 5 '15 at 15:25
• Thanks a lot, ybeltukov, I will upvote your answer! Much appreciated. – jarm Nov 6 '15 at 7:16