# Plotting a Gravity-Field [duplicate]

I try to plot a 2D gravity field or something similar in the form like $$r/|r|^3$$ with the standart builtin VectorPlot function:

VectorPlot[{-x/(x^2 + y^2)^(3/2), -y/(x^2 + y^2)^(3/2)}, {x, -5, 5}, {y, -5, 5}]


It should look like:
(source: euclideanspace.com)

I get something strange when I run my command:

Any suggestions?

Thanks Cx

You need VectorPoints to be adjusted, also, gravity explodes for point mass so it is good to adjust VectorScale and cut off the point mass with RegionFunction:

VectorPlot[-#/Norm[#]^3 &[{x, y}], {x, -1, 1}, {y, -1, 1},
VectorPoints -> 20, VectorScale -> .3,
RegionFunction -> (Norm[{#, #2}] > .1 &),
ImageSize -> 500, PlotRange -> 1]


In order to reproduce your plot you need to play with VectorScale 3rd element:

VectorPlot[-#/Norm[#]^3 &[{x, y}], {x, -1, 2}, {y, -1, 1}, VectorPoints -> 30,
VectorScale -> {.1, Automatic, (#5)^(1/3) &},
RegionFunction -> (Norm[{#, #2}] > .1 &), ImageSize -> 500,
PlotRange -> {{-1, 2}, {-1, 1}}, VectorStyle -> "Pointer",
GridLines -> ({#, #} &[Join[Range[-1, 2, .1], {{0, Directive[Thick, Blue]}}]]),
Epilog -> {EdgeForm[{Thick, Blue}], Red, Disk[{0, 0}, .05]},
AspectRatio -> Automatic]


• Thanks for your answer. But if I apply VectorDensityPlot to the same function argument I get still strange results (no decay). – cxkoda Nov 14 '13 at 12:54
• @cxkoda You have to play with ColorFunction the reason is the same. This field is exploding in the center and rescaled values are not different enough on the most of the area. – Kuba Nov 14 '13 at 12:59
• I wonder why I haven't thought about that. Now everthing is clear, thank you very much. – cxkoda Nov 14 '13 at 13:08
• Can you explain to me how RegionFunction -> (Norm[{#, #2}] > .1 &) works? I know # means slot, but what is it in this case? Replacing them with x and y doesn't work. – Cazo May 31 at 21:59
• @Cazo RegionFunction should be a function that will be used like regF[ x, y ] internally, where x, y are coordinates of points. You can write Function[{x,y}, Norm[{x,y}... or you can use slots instead of named arguments:  Norm[{#, #2}...&. – Kuba Jun 1 at 6:52