3

The main idea, is to plot an electric field lines with arrows on it, something like this: enter image description here

My solution is:

\documentclass[tikz, border=1cm]{standalone}
\usepackage{ pgfplots}
\usetikzlibrary{decorations.text, decorations.markings}
\usetikzlibrary{intersections}
\usetikzlibrary{arrows}  

\pgfplotsset{
    every axis label/.append style={font=\small},
    compat=newest,
}


\begin{document}
  \begin{tikzpicture}[xscale=1,yscale=1]
  \pgfmathsetmacro{\ea}{1.5}
  \pgfmathsetmacro{\eb}{1}
  \draw[red, samples=200, smooth] plot[id=curve, raw gnuplot] function{
    f(x,y) = (0.3 + ((\ea-\eb)/(\ea+2*\eb))/(x**2 + y**2))*y ;
    set xrange [-4:4];
    set yrange [-2:2];
    set view 0,0;
    set isosample 1000,1000;
    set cntrparam levels 50;
    set cont base;
    unset surface;
    splot f(x,y)
  } ;
  \fill[gray!50, draw=blue, thick] (0,0) circle (1.01);

  \clip (0,0) circle (1);
  \foreach \i in {-0.9,-0.675,...,1} {
  \draw[red, decoration={
      markings,
      mark=at position 0.5 with {\arrow{latex'}}}, postaction={decorate}] (-1,\i) --  (1,\i);
  }
  \end{tikzpicture}
\end{document}

But I have no good idea how to put an arrow in arbitrary position on curve (like I do for middle region lines)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.