Skip to main content
added 306 characters in body
Source Link
C. E.
  • 71.7k
  • 7
  • 144
  • 279

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}}] } ] 

Mathematica graphics

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} ] 

Mathematica graphics

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]} ]] 

Mathematica graphics

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}}] } ] 

Mathematica graphics

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} ] 

Mathematica graphics

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.

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}}] } ] 

Mathematica graphics

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} ] 

Mathematica graphics

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]} ]] 

Mathematica graphics

Source Link
C. E.
  • 71.7k
  • 7
  • 144
  • 279

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}}] } ] 

Mathematica graphics

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} ] 

Mathematica graphics

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.