# In PGFplots, how can I have arrows as markers for plots in order to have them appear in the legend?

In my plot, I want to indicate the direction of a graph with arrows.

Usually, I would just create something like this:

\begin{tikzpicture}
\begin{axis}[
axis x line=center,
axis y line=center,
xmax=3.5,xmin=-4,
ymax=6,ymin=-4,
xlabel=$x_1$,
ylabel=$x_2$,
xtick=\empty,ytick=\empty
]
\pgfmathsetmacro{\arronestart}{-(-0.6/1.5+0.1)^2+2};
\pgfmathsetmacro{\arroneend}{-(-0.59/1.5+0.1)^2+2};
\draw[
decoration={markings,mark=at position 1 with {\arrow[ultra thick]{stealth}}},
postaction={decorate}
] (axis cs:-0.6,\arronestart) -- (axis cs:-0.59,\arroneend);
\pgfmathsetmacro{\arrtwostart}{-(2.69/1.5+0.1)^2+2};
\pgfmathsetmacro{\arrtwoend}{-(2.7/1.5+0.1)^2+2};
\draw[
decoration={markings,mark=at position 1 with {\arrow[ultra thick]{stealth}}},
postaction={decorate}
] (axis cs:2.69,\arrtwostart) -- (axis cs:2.7,\arrtwoend);
\end{axis}
\end{tikzpicture}


Now, what I would like to have is a legend entry for those arrows, something like: ->- , but of course this is not possible with \draw[] ;. So, is there a way to have arrows as markings, so that I can create the same graph just using \addplot instead of \draw and have a proper legend?

-
Do graphs have directions? –  Thorsten Donig Jul 31 '11 at 10:34
I am not sure, but I think they don't. –  mSSM Jul 31 '11 at 14:07

You can use the \addlegendimage command to document custom draw statements:
        \draw[red,->] (axis cs:0,1) -- (axis cs:1,2);

Here, the \addlegendimage provides the options to visualize the legend entry and \addlegendentry provides the text.