# Access label, title in pgpfplots

I would like to know if is possible to access the standard nodes in pgfplots such as ylabel, xlabel, title. I am pretty sure this is quite easy, since each node should have a name by which it can be called, but I don't know how to figure this name out and the name, I would expect them to have, does not exist.

## MWE

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[title={Some title}, ylabel={ylabel}, xlabel={xlabel}]
% Does not work
\draw (ylabel.center) -> (title.center);
\draw (ylabel.center) -> (xlabel.west);
\end{axis}
\end{tikzpicture}
\end{document}


The nodes aren't named by default, but you can assign names yourself using title style={name=title}, for instance. The title and labels are generated at the very end of the axis environment, so if you want to refer to these nodes, you'll have to mode your TikZ commands outside the axis environment.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={Some title}, title style={name=title},
ylabel={ylabel}, ylabel style={name=ylabel},
xlabel={xlabel}, xlabel style={name=xlabel}
]

• thanks for the quick answer, too bad that the nodes cannot be accessed inside the axis-environment, not even with after end axis/.code. I would have expected them to be defined earlier. – maetra Jul 30 '13 at 16:05
• I am trying to draw a line from the left to the right of the whole graph, which I use for a custom legend. The point most far to the left, is determined by the ylabel and for the right side I use (rel axis cs:1,0). Apart from the axis environment (rel axis cs:1,0) is not correct anymore, but shifted to the left. This not a big problem, since I split the drawing in two parts, but for the legend text this is a pain. – maetra Jul 30 '13 at 16:31
• @maetra: In that case, a better approach would be to use \draw (current axis.outer west) -- (current axis.outer east); outside the axis environment. That approach is more robust, since it will also work in cases where you don't have a ylabel, for example. – Jake Jul 30 '13 at 16:35