# pgfplots: how to add a label to a graph with the option clip=true?

## Question

I would like to add a label to my graph, on the right of it or at any other place, for instance somewhere above my graph.

Is it possible?

I want to use the option clip=true, because of the graph of tan(x) (see the picture below)

## Code and picture

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line = middle,
axis y line = middle,
domain=-2:2,
xmin = -2,
xmax = 2,
ymin=-10,
ymax=10,
grid = major,
clip = false]
\addplot[color=orange, samples=100, smooth, ultra thick] {tan(deg(x))}  node[right] {$\tan$};
\end{axis}
\end{tikzpicture}

\end{document}


If I remove the options ymin=..., ymax=..., the output is fine, but I would like, if possible, to set the values of ymin and ymax.

-

You can set clip mode=individual to clip only the plot lines. However, this also clips nodes added at the end of the plot like in your code, as it is part of the same path. As a workaround you could add an empty, named node at the end of the plot, and place a new node at this location.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = middle,
domain=-2:2,
xmin = -2,
xmax = 2,
ymin=-10,
ymax=10,
grid = major,
clip = true,
clip mode=individual]
\addplot[color=orange, samples=100, smooth, ultra thick] {tan(deg(x))}  node (endofplot) {};
\node [right,orange] at (endofplot) {$\tan(x)$};
\end{axis}
\end{tikzpicture}

\end{document}

-
Great! Thanks a lot for your help! As you might have guessed, I am writing a command to draw automatically functions on a graph! –  Colas Apr 7 '14 at 13:04