# How to adjust vector scaling with a specific aspect ratio

I'm trying to create a vector plot with uniform vector scaling. I need the x and y ranges to be very different, because I need to highlight the angle between the vectors and the y=0 axis. This means that I can't use an automatic aspect ratio, however, changing the aspect ratio is changing the vector scaling in a way that I don't understand.
This is my code

Show[VectorPlot[{If[y>0, 1-2x, 1-x], If[y>0, -6/25+2/5x-3/2y, -7/25+2/5x-1/2y]},
{x,0.49,0.8}, {y,-0.01,0.01}, VectorStyle->Black, VectorPoints->Coarse,
VectorScale->{0.05, 1, None}, AspectRatio->0.62],
ContourPlot[y==0, {x,0.48,0.8}, {y,-0.01,0.01}, ContourStyle->{Black}]]


which gives the following vector plot I specifically need the arrows on the top left to be approximately the same size as the rest of them, and to not cross the y=0 axis. I've also entered specific functions into sfun, for instance

Show[VectorPlot[{If[y>0, 1-2x, 1-x], If[y>0, -6/25+2/5x-3/2y, -7/25+2/5x-1/2y]},
{x,0.49,0.8}, {y,-0.01,0.01}, VectorStyle->Black, VectorPoints->Coarse,
VectorScale->{0.05, 1, #2&}, AspectRatio->0.62],
ContourPlot[y==0, {x,0.48,0.8}, {y,-0.01,0.01}, ContourStyle->{Black}]]


which should give a uniform vector length for the same y values, but instead gives the picture below, where there is the same vector length problem in the upper left corner. Is there a way to scale the vectors so that this doesn't happen?

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Jan 1, 2016 at 22:25
• Jan 1, 2016 at 22:30
• I don't think it is really a duplicate. It turned out that figuring out the rescaling was a bit tricky, esp. because VectorPlot was changing the plot range so that it didn't not match the plot domain. See my answer. Jan 1, 2016 at 23:06
• Jan 1, 2016 at 23:22

You have to scale the (x,y)-components of the vectors so that they correspond to the horizontal and vertical units on the screen. That means scaling (1) according to the PlotRange and (2) according to the AspectRatio.

Show[VectorPlot[{If[y > 0, 1 - 2 x, 1 - x],
If[y > 0, -6/25 + 2/5 x - 3/2 y, -7/25 + 2/5 x - 1/2 y]}, {x, 0.49,
0.8}, {y, -0.01, 0.01},
VectorStyle -> Black, VectorPoints -> Coarse,
VectorScale -> {1/20, 1,
Function[{x, y, fx, fy, norm},
If[norm > 0,
norm/Sqrt[(fx/(0.8 - 0.49))^2 + (0.62 fy/(0.01 - (-0.01)))^2],
0]]},
AspectRatio -> 0.62, PlotRange -> All],
ContourPlot[y == 0, {x, 0.48, 0.79}, {y, -0.01, 0.01},
ContourStyle -> {Black}]
] Note: Adding PlotRange -> All was essential. VectorPlot was automatically extending the plot range, making it difficult to get the rescaling correct.