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.

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: what it should look like

I get something strange when I run my command:

what i get

Any suggestions?

Thanks Cx

share|improve this question

marked as duplicate by Artes, Kuba, rm -rf Nov 14 '13 at 14:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

up vote 6 down vote accepted

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]

enter image description here

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]

enter image description here

share|improve this answer
    
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

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