Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

LaTeX Streamlines for a vector field

  1. Jan 5, 2019 #1
    I'm trying to use LaTeX to graph both the vectors of the electric field around a dipole and the field lines. So far I have a quiver plot of the vector field:

    bXuS0fO.png

    I obtained this by using the code

    Code (Text):

    \begin{tikzpicture}

    \def \U{(x-1)/((x-1)^2+y^2)^(3/2) - (x+1)/((x+1)^2+y^2)^(3/2)}
    \def \V{y/((x-1)^2+y^2)^(3/2)-y/((x+1)^2+y^2)^(3/2)}
    \def \LEN{(sqrt((\U)^2 + (\V)^2)}

    \begin{axis}
    [domain = -3:3, domain = -3:3, view={0}{90}]
    \addplot3
    [
    blue,
    point meta={\LEN},
    quiver={
            u={(\U)/\LEN},
            v={(\V)/\LEN},
            scale arrows=0.2,
            every arrow/.append style={line width=\pgfplotspointmetatransformed/1000 * 2pt},
            },
            -stealth,
            samples=15,
        ] {0};
    \end{axis}
    \end{tikzpicture}
    The code makes all of the vectors have the same length. In theory, it would also scale their thickness but as you can see nearly all of the vectors besides those right next to the charges at (-1,0) and (+1,0) have the minimum thickness, I guess because the field drops off in intensity so quickly. I would take that out but for some reason doing so makes it look just a little bit off.

    Anyway, what I'd like to do now is also draw some field lines on top of this quiver plot, so that I can have a graphic that shows how the electric field vectors are tangent to the field lines. Is there any way I can do this elegantly in LaTeX without having to plot the field lines explicitly?
     
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?