[Tex/LaTex] PGFPlots Parametric Plot, Arrow Spacing by Constant Time

arrowspgfplotstikz-pgf

For a parametric plot of a particle's position (x(t),y(t)), is it possible to usepgfplots to draw arrows equally spaced in time to indicate the direction of travel?

For example, with (x(t),y(t)) = (t,t^2), I know how to produce arrows equally spaced in length:

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{decorations.markings}
\pgfplotsset{compat=1.8}

\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines = middle,smooth,xlabel = $x$, ylabel =$y$, minor tick num =1, grid=both, unit vector ratio*=1 1,enlargelimits = true]
\addplot[thick, variable=\t, domain=0:2, decoration={
    markings,
    mark=between positions 0.2 and 0.99 step 2em with {\arrow [scale=1.5]{stealth}}
    }, postaction=decorate] ({t^2}, {t^4});
\end{axis}
\end{tikzpicture}

\end{document}

yielding

enter image description here

But can I get constant spacing in time, similar to:

enter image description here

Best Answer

You could make use of the quiver plot handler which is shipped with pgfplots. The quiver plot handler draws arrows at every input sample.

To this end, it requires the input coordinates as usual and arrow coordinates for every input coordinate (i.e. x,y, u, v).

In your case, we could easily sample all required values. Since you have unit vector ratio*=1 1 in your listing, we can normalize all arrows to length 0.1 as follows:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
width=14cm,
axis lines = middle,smooth,xlabel = $x$, ylabel =$y$, minor tick num =1, grid=both, unit vector ratio*=1 1,enlargelimits = true]
\addplot[smooth, thick, -stealth,variable=\t, domain=0:2]
    ({t^2}, {t^4});

\def\NORM{sqrt((2*t)^2 + (4*t^3)^2)}
\addplot[thick, red,-stealth,samples=12,variable=\t, domain=0.1:2,quiver={
        u=2*t/\NORM, v=4*t^3/\NORM,
        scale arrows=0.1,
    }]
    ({t^2}, {t^4});
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

The \NORM is the vector norm of the vector (u,v); together with scale arrows=0.1, we get the desired effect. Here, we need two \addplot statements: one which draws the plot as such and one which draws merely the arrows.

For comparison, here is the same figure with scale arrows=1:

enter image description here