# anchor point on a self loop (to draw a line from that anchor point)

I would like to annotate self loops of a graph, that is write a tiny line starting from the self loop and going to some text. My problem is that I don't know how to get access to the "anchor point" corresponding to the point where the self loop "turns back". The following code does this manually by computing (by try and error) a shift from the node where the self loop is attached. But this is not nice since the size of my node depends on the text inside the node (which can change in my context).

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\node [circle, draw, font=\scriptsize] (n1) at (0,0) {$1$};
\path[->] (n1) edge [in=-10,out=20,loop] node {} (n1);
\path[draw=black!80,line width=0.6pt,dotted] ($(n1)+(0.7cm,0cm)$) to ($(n1)+(1.36cm,0cm)$) node[right] {\tiny annotation};
\end{tikzpicture}

\end{document}

• Dear @Nicolas Beldiceanu, you have asked (at the moment) 5 questions, but you have accepted none of the (8) answers. If you think that an answer respond to your question, it is a good thing to validate it (by clicking on the check mark on the left of the question). This helps to keep the list of "unanswered" questions consistent. And is a small compensation for the people that tries to help you. – Kpym Dec 30 '14 at 7:38
• The answers were quite helpful, but I dont see the check mark you mention. I only see "share" "edit" "delete" "flag" "Add Comment" "active" "oldest" "votes" marks. – Nicolas Beldiceanu Dec 30 '14 at 8:05
• Sorry "on the left of the answer" not "the question". Here is the explanation of how to do it meta.stackexchange.com/questions/5234/… – Kpym Dec 30 '14 at 8:23

Use a coordinate at some position along the self loop.

Omit [pos=0.52] in the code below to use the default (midway, or, equivalently, pos=0.5) to take the literal midpoint of the curved edge. I've slightly adjusted it to pos=0.52 in the code here to show fine-tuning you can do if desired.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\node [circle, draw, font=\scriptsize] (n1) at (0,0) {$1$};
\path[->] (n1) edge [in=-10,out=20,loop] coordinate[pos=0.52] (midp) (n1);
\path[draw=black!80,line width=0.6pt,dotted] (midp) -- +(1,0) node[right] {\tiny annotation};
\end{tikzpicture}

\end{document}


You can use pin to do this. But, as explained here https://tex.stackexchange.com/a/219984/9335, we have to reset the pin edge style before.

\documentclass[tikz,border=10]{standalone}
\tikzset{every pin edge/.append style={bend left=0,>={},->}}
\begin{document}
\begin{tikzpicture}
\node [circle, draw, font=\scriptsize] {$1$}
edge [in=-10,out=20,loop,->] node[pos=0.52,pin=0:\tiny annotation]{} ();
\end{tikzpicture}
\end{document}