How does one draw a path that is changing color as a function of the path length and is decorated with arrows at the same time? Basically, I want to combine these to figure into one:
The code for the example is:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}
\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}
\begin{scope}
\draw[->, ultra thick, >=stealth, line cap=round] (0.0, -2.5) -- (0.0, 2.5);
\draw[->, ultra thick, >=stealth, line cap=round] (-2.5, 0.0) -- (2.5, 0,0);
\begin{axis}[x=1cm, y=1cm, ticks=none, axis lines=none, colormap/hot, anchor=origin]
\addplot[mesh, ultra thick, point meta=\thisrow{c}, shader=interp] table[x=x, y=y] {spiral.dat};
\end{axis}
\end{scope}
\begin{scope}[xshift=6cm]
\draw[->, ultra thick, >=stealth, line cap=round] (0.0, -2.5) -- (0.0, 2.5);
\draw[->, ultra thick, >=stealth, line cap=round] (-2.5, 0.0) -- (2.5, 0,0);
\draw[ultra thick] plot file {spiral_xy.dat} [arrow inside={end=stealth,opt={black, scale=1.05}}{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}];
\end{scope}
\end{tikzpicture}
\end{document}
For the arrow tips I used the solution from Drawing arrows along a function in pgfplots. However, this does not seem to be compatible with the pgfplots mesh command I am using to draw a colored line. I was thinking to combine a mesh and a quiver plot but then the arrow tips would not change color along with the curve. As an alternative one could define a custom fading with \fadingfrompicture
but this would be a lot of work for complicated curves. Is there a more simple solution?