Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
    
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.) –  murray Feb 24 '13 at 23:20

2 Answers 2

up vote 8 down vote accepted

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

vectors

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.

share|improve this answer
    
+1 So I always like to add an equipotential contour-line plot as the background. –  Silvia Feb 24 '13 at 5:29
    
@Silvia yes, but of course you can only do that if your vector field is conservative (i.e., irrotational). –  Jens Feb 24 '13 at 5:31
    
@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 –  Jens Feb 24 '13 at 5:38
    
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. –  Silvia Feb 24 '13 at 5:39
    
Yes field strength is what I meant :P –  Silvia Feb 24 '13 at 5:40

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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