# Plotting a Gravity-Field [duplicate]

This question already has an answer here:

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:

I get something strange when I run my command:

Any suggestions?

Thanks Cx

-

## marked as duplicate by Artes, Kuba, R. M.♦Nov 14 '13 at 14:04

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