I am trying to make a simple plot of a spherical field falling off with distance from origin:

VectorPlot[{x, y} / EuclideanDistance[{0, 0}, {x, y}]^2, {x, -3, 3}, {y, -3, 3}]

I just get dots. Why do I get this?

enter image description here

  • $\begingroup$ Note that you can replace the denominator of the fraction by the simpler Norm[{x, y}]^2. (But you would probably prefer keeping EuclideanDistance in case the center were not at the origin.) $\endgroup$
    – murray
    Feb 24, 2013 at 23:20

2 Answers 2


The problem is that the singularity of the field dominates the scale chosen for the vector arrow size. You have to introduce a cutoff into the function that determines the scale:

With[{maximumModulus = 10}, 
 VectorPlot[{x, y}/EuclideanDistance[{0, 0}, {x, y}]^2, {x, -3, 
   3}, {y, -3, 3}, 
  VectorScale -> {Automatic, Automatic, 
    If[#5 > maximumModulus, 0, #5] &}]


The magic happens in the VectorScale option where the third entry in the list is a function that filters out values of the field that exceed the maximumModulus cutoff. This is done by setting the excessively large field value(s) to zero so there won't be an arrow for them. This happens right in the center of the plot.

Some alternative ways to visualize vector fields with singularities are discussed here - that was in the context of a complex variable, but it's ultimately the same problem. I repeated this answer here because your question is not about complex fields.

  • $\begingroup$ +1 So I always like to add an equipotential contour-line plot as the background. $\endgroup$
    – Silvia
    Feb 24, 2013 at 5:29
  • $\begingroup$ @Silvia yes, but of course you can only do that if your vector field is conservative (i.e., irrotational). $\endgroup$
    – Jens
    Feb 24, 2013 at 5:31
  • $\begingroup$ @Silvia actually, your comment on the background coloring can always work if you make the color plot not for the potential but for the field strength instead. That's what I did here $\endgroup$
    – Jens
    Feb 24, 2013 at 5:38
  • $\begingroup$ Well there will always be equi-magnitude level lines :) And in that case I would prefer StreamPlot with color-blending along stream-lines for indicating the magnitude. $\endgroup$
    – Silvia
    Feb 24, 2013 at 5:39
  • 1
    $\begingroup$ Thank you, Jens. I just encountered this same problem. Diagnosing what the problem may be I tried to get around it with a suitable RegionFunction. To no avail. Apparently that is applied after Mathematica has decided on a scale. $\endgroup$ Nov 13, 2014 at 11:55

An alternative is to use StreamPlot, for example as follows:

StreamPlot[{x, y}/EuclideanDistance[{0, 0}, {x, y}]^2,
    {x, -3, 3}, {y, -3, 3},
    VectorPoints -> 13,
    StreamStyle -> None]

which produces a similar result

enter image description here

Depending on the number of VectorPoints you use, a plot will appear with only points as in the original problem. I presume this also has to do with the vector placement/sampling and the singularity in the vector field being plotted.

Experimenting with the VectorPoints, StreamStyle and other options to the StreamPlot function may lead to more appealing visualizations. Note that in the plot shown here, the 'stream' portion of the StreamPlot has been hidden.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.