Be able to input (x,y) and Coulombs of point on plane and generate electric field plot. Also be able to add as many points as possible.

Thanks This is what I want, but not random points:

Electric Field Plot

q = RandomReal[{-1, 1}, 6];
r0 = RandomReal[{-3, 3}, {6, 2}]
q = q - Total[q]/6;
phi = Sum[
   q[[i]]/Sqrt[({x, y} - r0[[i]]).({x, y} - r0[[i]])], {i, 1, 6}];
f = -Grad[phi, {x, y}]

Show[StreamPlot[Evaluate[f], {x, -4, 4}, {y, -4, 4}, 
  StreamColorFunction -> "Rainbow", 
  StreamColorFunctionScaling -> False], 
   If[q[[i]] < 0, {Blue, PointSize[.1*Abs[q[[i]]]], 
     Point[r0[[i]]]}, {Red, PointSize[.1*Abs[q[[i]]]], 
     Point[r0[[i]]]}], {i, 1, 6}]]]
  • 1
    $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, [by clicking the checkmark sign](tinyurl.com/4srwe26 $\endgroup$
    – Dunlop
    Commented Feb 4, 2020 at 5:35
  • 1
    $\begingroup$ Please be more precise in what you are asking. Can you show code of what you have tried? $\endgroup$
    – Dunlop
    Commented Feb 4, 2020 at 5:35
  • 1
    $\begingroup$ mathematica.stackexchange.com/questions/197715/… How do I do what the person who answered did, but be able to add my own specific points? $\endgroup$ Commented Feb 4, 2020 at 6:45
  • 1
    $\begingroup$ @TarangJanawalkar you just put the points how & where you want them. It’s quite simple if you understand how the code works—q dictates how much charge each point has and r0 creates their physical location. I would recommend you ask for clarification on the question in particular. Now, if you wanted to ask how to make a dynamic manipulate type of thing from this, I think that would make for a good question. Think something like clicking to add points then moving them around as you please? $\endgroup$ Commented Feb 4, 2020 at 7:02
  • 1
    $\begingroup$ @CATrevillian thanks for that, yes I know it's simple but I am learning the Wolfram Language, so I don't really know that much. Can I move them around easily? or will that take too much time? $\endgroup$ Commented Feb 4, 2020 at 7:11


Browse other questions tagged or ask your own question.