TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Usually, I would just create something like this:

        axis x line=center,
        axis y line=center,
    \addplot[smooth,domain=-3.5:2.7,mark=none,black]{-(x/1.5+0.1)^2 + 2};
     decoration={markings,mark=at position 1 with {\arrow[ultra thick]{stealth}}},
     ] (axis cs:-0.6,\arronestart) -- (axis cs:-0.59,\arroneend);
     decoration={markings,mark=at position 1 with {\arrow[ultra thick]{stealth}}},
     ] (axis cs:2.69,\arrtwostart) -- (axis cs:2.7,\arrtwoend);

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?

share|improve this question
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
up vote 5 down vote accepted

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.

share|improve this answer
Great, that really helps. Thank you! – mSSM Jul 31 '11 at 23:23

Your Answer


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.