# Proper way to align labels with nodes tikz

Consider the following code:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}

\coordinate (A) at (1,1);
\coordinate (B) at (2,2);

\draw[->] (A) -- (B);

\draw[dashed] (0,0) rectangle (3,3) node (C) {};

\draw [solid] ($(A.south west)-(0,1.5)$) -- ++(0.5, 0) node [label =right:Signalling] {};

\end{tikzpicture}
\end{document}


How can I properly align the end of label, with the edge of rectangle in a automated way?

-
@cacamailg I added the picture. I hope that is okay. –  hpesoj626 Mar 30 '13 at 23:34
I am interested in the pgfplots solution. Can you add a MWE? –  cacamailg Mar 30 '13 at 23:34
The corners of the rectangle seem to have a problem. They should look like L-shape broken lines actually. –  kiss my armpit Mar 30 '13 at 23:38
@hpesoj626 that is ok, thanks. –  cacamailg Mar 30 '13 at 23:40
@Karl'sstudents I didn't understand what you mean. Instead of dashed you can use solid for the rectangle. –  cacamailg Mar 30 '13 at 23:41

Two options;

With TikZ, you can use the name of the node for a later use in this context;

\documentclass[tikz]{standalone}
\begin{document}

\begin{tikzpicture}
\coordinate (A) at (1,1);
\coordinate (B) at (2,2);
\draw[->] (A) -- (B);
\draw[dashed] (0,0) rectangle (3,3) node (C) {};

\draw node[% Note that we are inside a path not inside a node declaration
anchor=east,
append after command={([xshift=-2mm]\tikzlastnode.west) -- ++ (-0.5,0)},
inner sep=0] at (3,-0.5) {Signalling};

\end{tikzpicture}
\end{document}


Or with pgfplots by actually drawing a function instead of giving it as a path;

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis line style=dashed,
xtick=\empty,
ytick=\empty,
legend pos={south east}
]
\end{axis}
\end{tikzpicture}
\end{document}


-
Thank you very much. Just a question in the 1st solution: [xshift=-2mm]\tikzlastnode.west is the same as ($(\tikzlastnode.west) + (-2mm,0)$)? –  cacamailg Mar 31 '13 at 0:29
@cacamailg Yes, but then you don't need calc library –  percusse Mar 31 '13 at 0:41