0
$\begingroup$

This question already has an answer here:

How would I plot a 2D field of a dipole but that has charge +q, and -q where they are on they y axis 4 units above and 4 units below the origin. and slice it along the xy plane? Any help on how you would do this?

$\endgroup$

marked as duplicate by m_goldberg plotting Sep 22 '17 at 12: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.

  • $\begingroup$ Do you have an example of the style of plot you wish to achieve? $\endgroup$ – Mr.Wizard Sep 22 '17 at 1:55
  • $\begingroup$ No I don't have a particular style as long as its a 2D slice in the xy plane $\endgroup$ – David Sep 22 '17 at 3:03
  • $\begingroup$ You could use SliceVectorPlot3D $\endgroup$ – b.gates.you.know.what Sep 22 '17 at 8:22
2
$\begingroup$

Here's a function that generates the three-dimensional electric field for a charge q located at position {x0, y0, z0}:

charge[q_, {x0_, y0_, z0_}][x_, y_, z_] := q/((x - x0)^2 + (y - y0)^2 + (z - z0)^2)^(3/2) {x - x0, y - y0, z - z0}

You can generate a three-dimensional vector plot:

VectorPlot3D[
    charge[1, {0, 4, 0}][x, y, z] + 
    charge[-1, {0, -4, 0}][x, y, z], 
{x, -10, 10}, {y, -10, 10}, {z, -10, 10}]

enter image description here

but to project it to the xy-plane is a little tricky

projector[{x_,y_,z_}]:={x,y}
VectorPlot[
    projector[
        charge[1, {0, 4, 0}][x, y, 0] +  
        charge[-1, {0, -4, 0}][x, y, 0]
    ], 
    {x, -10, 10}, {y, -10, 10}]

doesn't look that good. Maybe someone can improve it.

vector plot

You can try StreamPlot instead.

StreamPlot[
    projector[
        charge[1, {0, 4, 0}][x, y, 0] +  
        charge[-1, {0, -4, 0}][x, y, 0]
    ], 
    {x, -10, 10}, {y, -10, 10}]

stream plot

$\endgroup$

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