# How to change tail position of VectorPlot vectors?

When I use VectorPlot[] to plot a vector field it looks like the vectors are placed with their midpoints at their points of evaluation. I.e. the vector $\textbf{F}(x,y)$ is positioned with its midpoint at $(x,y)$.

I think it looks more natural when the vectors are placed with their tails at their evaluation points. Is this possible to change?

You are right, this confirms that vectors are placed with their midpoints at their points of evaluation:

vp = VectorPlot[
{y, -x}, {x, -3, 3}, {y, -3, 3},
VectorPoints -> {{1, 1}, {-1, 1}, {1, -1}, {-1, -1}},
Epilog -> {
Red, PointSize[Large],
Point[{{1, 1}, {-1, 1}, {1, -1}, {-1, -1}}],
Green, Point[{{1.214, -0.785}, {0.785, -1.214}}]
}
]


In this example we told VectorPlot to plot arrows in four specific places. We then plotted red points in those specific places, and as expected the points turned up in the middle of the arrows. Here is how to change it:

vp /. Arrow[{pt1_, pt2_}] :> Arrow[
{pt1, pt2},
{Norm[pt1 - pt2]/2, -Norm[pt1 - pt2]/2}
]


VectorPlot generates graphics directives of the form Arrow[{pt1, pt2}]. In fact, I got the coordinates for the green points by inspecting the graphics object with FullForm. My solution is to replace all expressions of the form Arrow[{pt1, pt2}] in the graphics object with a similar expression, utilizing the third argument of Arrow to get the desired adjustment.

If you are using VectorStyle -> "Segment" to plot lines instead of arrows, you can similarly use

vp /. Line[l : {p1 : {_, _}, p2 : {_, _}}] :> With[{m = Mean[l]}, Line[
{m, m + Normalize[m - p1] Norm[p2 - p1]}
]]


• Forgive my ignorance, but what do I do with that piece of code? Dec 12, 2016 at 15:50
• @PGmath Graphics in Mathematica are expressions, in the form Graphics[{...}] or Graphics3D[...]. You can look those two up in the documentation. Plot functions are functions that generate Graphics and Graphics3D expressions. My solution is a replacement rule that will rewrite the expression, particularly the Arrow primitives that VectorPlot created. For a great explanation of this concept please read this. The short answer is: you take the replacement rule ./ Arrow... and put it right after VectorPlot[...]. Dec 12, 2016 at 16:02
• Is there a version of this that works for VectorStyle -> "Segment"? I tried it this way and it didn't change anything. Dec 14, 2016 at 5:22
• @PGmath That would have been a nice exercise for you, but nevertheless I posted something. Dec 14, 2016 at 8:41
• Thank you. I did try to monkey with that code a bit but everything I tried either threw an error or didn't do anything. Dec 14, 2016 at 15:27