2

I have the following code, and I've tried almost everything I can think of, even VectorColorFunction to describe magnitude. I am trying to make the length of the vectors proportional to r^{-2}, and without Norm[efield] it only plots a single arrow. Here is what I have:

f[x_, y_] = (x^2 + y^2)^(-1/2); 
efield = g[x_, y_] = Grad[f[x, y], {x, y}];

VectorPlot[(-efield)/Norm[efield], {x, -10, 10}, {y, -10, 10},
 AspectRatio -> Automatic, VectorScale -> {Medium, Scaled[0.35]}]

The vectors are all the same length; any ideas?

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
user19781
  • 21
  • 1

1 Answers1

2

This seems to do the right thing:

VectorPlot[(-efield), {x, -10, 10}, {y, -10, 10}, AspectRatio -> Automatic, VectorScale -> {Automatic, Automatic, 1/#5^2 &}]

(although you might want to twiddle the scaling parameter). Notice that the scaling function is a function of five parameters, of which the norm of the gradient is the last, hence #5.

Igor Rivin
  • 5,094
  • 20
  • 19