Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How does one insert arbitary placed arrows along a curve/function defined in pgfplots using the \plot command. I realise the last sentence became a tad long.. Below is a simple code for which I am trying to insert arrows, if I had points to go after, I could have used something like Pgfplots: Drawing Arrows Along Contour Plots or decorations. But this does not work here...

Earlier i asked the same question with the draw function Add arrows to a smooth tikz function, and obtained a really good answer. However implementing the solution directly to the code under gives missfortunate 'stack overflow' error. To summarize

  • Is there a way to place a number of arrows a long a function / curve made with pgfplots?

Presumably with a similar syntax to

\draw plot ... [arrow inside={end=stealth,opt={scale=2}}{0.25,0.5,0.75}];

Here is one figure I am trying to add a few arrows too

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset{
    set arrow inside/.code={\pgfqkeys{/tikz/arrow inside}{#1}},
    set arrow inside={end/.initial=>, opt/.initial=},
    /pgf/decoration/Mark/.style={
        mark/.expanded=at position #1 with
        {
            \noexpand\arrow[\pgfkeysvalueof{/tikz/arrow inside/opt}]{\pgfkeysvalueof{/tikz/arrow inside/end}}
        }
    },
    arrow inside/.style 2 args={
        set arrow inside={#1},
        postaction={
            decorate,decoration={
                markings,Mark/.list={#2}
            }
        }
    },
}
\begin{document}
\begin{tikzpicture}
\draw node [circle] at (-1,0) {$z_0$};
\begin{scope}[very thick,rotate=45,decoration={
    markings,
    mark=at position 0.5 with {\arrow{>}}}]
\draw[domain=0:6.28,samples=200,smooth,] plot (xy polar
cs:angle=\x r,radius=      {1-sin(2*\x r)}) ;
\end{scope}
\end{tikzpicture} 
\end{document}

Lemniscate

share|improve this question
    
Are you committed to doing this with pgfplots? It's easy enough in Metapost - you can make your function a path and then draw arrows along subpaths of it. –  Thruston Mar 9 at 18:28
    
I can't see any use of pgfplots in your question. Is there a particular reason for that? Because I already have an answer for your MWE. –  Henri Menke Mar 9 at 23:56

1 Answer 1

up vote 5 down vote accepted

As you didn't answer my comment yet, I will just post my solution to the problem I think you are trying to solve.

You may just use the code, given in my answer to this question: Add arrows to a smooth tikz function Next you will need to remove the smooth statement, because it will interfere with decorate and give you nice errors like ? Dimension too large. This won't have an effect on the smoothness of your drawing, because you already use sufficiently many samples.

Implementation

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset{
  set arrow inside/.code={\pgfqkeys{/tikz/arrow inside}{#1}},
  set arrow inside={end/.initial=>, opt/.initial=},
  /pgf/decoration/Mark/.style={
    mark/.expanded=at position #1 with
    {
      \noexpand\arrow[\pgfkeysvalueof{/tikz/arrow inside/opt}]{\pgfkeysvalueof{/tikz/arrow inside/end}}
    }
  },
  arrow inside/.style 2 args={
    set arrow inside={#1},
    postaction={
      decorate,decoration={
        markings,Mark/.list={#2}
      }
    }
  },
}
\begin{document}
\begin{tikzpicture}
  \draw node [circle] at (-1,0) {$z_0$};
  \begin{scope}[very thick,rotate=45]
    \draw[domain=0:6.28,samples=200] plot (xy polar cs:angle=\x r,radius={1-sin(2*\x r)}) [arrow inside={}{0.25,0.5,0.75}];
  \end{scope}
\end{tikzpicture} 
\end{document}

Output

enter image description here

share|improve this answer
1  
You may add -- cycle to close the curve. –  Paul Gaborit Mar 13 at 6:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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