I want to plot the following vector field in 2D, using the built in function VectorPlot:
Because the variation in modulus is typically several orders of magnitude, Mathematica’s arrows are quite large near the source point, the point
, and are very short at the edge of the plot.
The way to solve this issue is to have the arrow lengths scaled logarithmically.
How can one do that in Mathematica? I came across the VectorScale option, and saw it accepts 3 arguments:
{unitlen,aratio,sfun}
As stated in the Documentation,
sfun is a scaling function that determines the width of vector boxes.
I think that the argument that is in interest for my purpose is sfun. But I need some help with writing down a command to be given there. Any help about it would be very appreciated.
Version 12.1 will start with a different default setting, which will greatly improve the default look of vector plots. The solution of Gianluca will suffice for now.
@Gianluca Gorni Thanks a lot for your quick reply, but although your method does produce a vector plot with a rather nice scaling, it doesn’t call for the VectorScale option I want to deploy. Could you address me on using this particular option?
The 5th slot is Norm[{fx,fy}]. But as the documentation to Mathematica 11 tells:
When using an explicit sfun, positive values are automatically scaled to lie between 0 and 1. For other values the vector is not drawn.
I.e. typing Log10 as I did wouldn’t give good results in all cases. The correct scaling function for one’s specific vector field and specific region of plotting is determined by the minimum value of Norm[{fx,fy}] (the shortest arrow in the plot) and maximum of Norm[{fx,fy}] (the longest arrow).
This makes the process of scaling vector field’s arrows a task to ponder about each time drawing a vector field.
I guess that Mathematica 12’s new VectorScale arguments are designed to specifically skip and save you from all this math calculations.
The bottom line, as I see it, is not to fiddle with it the way I tried to, but rather to do it as @Gianluca Gorni did, tuck your vector field inside a scaling function.