# Self-loops in graphs change their shapes when the picture is rotated

I am using tkz-graph for drawing graphs. Self-loops change their shapes when the picture is rotated. Is this normal? Since I could probably redesign the rotated graph from the beginning, I am more interested in knowing why the behaviour occurs, or whether I am doing something wrong than in solving the problem. An example follows.

\documentclass{article}
\usepackage{tkz-graph}
\newcommand{\tp}[1]{\begin{tikzpicture}[rotate=#1]
\Vertex{a}
\Loop(a)
\end{tikzpicture}}

\begin{document}
\tp{0}

\tp{90}

\tp{180}

\tp{270}
\end{document}

• If the angles are just the one on your example we can also go to other solutions and use \Loop. But I think the code can not remain so simple as yours. – koleygr Aug 31 '17 at 14:23
• I edited my answer and think that it is more clear now. – koleygr Aug 31 '17 at 15:55

Edit in it's source it has:

\let\loop\grLoop


And grLoop is defined as:

\newcommand*{\grLoop}[1][]{\tkzGR@loop[#1]}%
\def\tkzGR@loop[#1](#2){%
\setkeys[GR]{loop}{#1}%
\protected@edef\@tempa{%
\noexpand \draw[\cmdGR@loop@color] (#2)%
edge [EdgeStyle,LoopStyle,\cmdGR@loop@style]%
node [LabelStyle,\cmdGR@loop@labelstyle]%
{\cmdGR@loop@label} (#2)}\@tempa;%
}%


So we have to check EdgeStyle,LoopStyle,\cmdGR@loop@style

But in initializing Loopstyle contains:

\define@choicekey*[GR]{loop}{dir}[\val\nr]{WE,EA,NO,SO,NOWE,NOEA,SOWE,SOEA}{%
\ifcase\nr\relax
\tikzset{LoopStyle/.style = {in=225, out=135, distance=\cmdGR@loop@dist}}%
\or
\tikzset{LoopStyle/.style = {in= 45, out=-45, distance=\cmdGR@loop@dist}}%
\or
\tikzset{LoopStyle/.style = {in=135, out= 45, distance=\cmdGR@loop@dist}}%
\or
\tikzset{LoopStyle/.style = {in=-45, out=-135, distance=\cmdGR@loop@dist}}%
\or
\tikzset{LoopStyle/.style = {in=180, out=90, distance=\cmdGR@loop@dist}}%
\or
\tikzset{LoopStyle/.style = {in=90, out=0, distance=\cmdGR@loop@dist}}%
\or
\tikzset{LoopStyle/.style = {in=-90, out=-180, distance=\cmdGR@loop@dist}}%
\or
\tikzset{LoopStyle/.style = {in=0, out=-90, distance=\cmdGR@loop@dist}}%
\fi%
}


And that means that the starting point does not initializing there (just angles and distance)

So looking for the other option I find that \cmdGR@loop@style is no refered anywhere else and that probably is empty.

So the package doesn't provides any option for real rotation.

And if I try a loop with the code:

\newcommand{\tp}[1]{\xdef\ea{#1+90}\begin{tikzpicture}[rotate=#1]
\Vertex{a}
\draw (a) edge [in=0, out=90,distance=40] (a);
\end{tikzpicture}}


I get the same problem. This problem is reproduced by \Loop command

If I could add to in or if latex was adding to it by the rotation it would by better. May be we have to fill a bug for no valid rotation of edge options.

\documentclass{article}
\usepackage{xcolor}
\usepackage{tkz-graph}
\newcommand{\tp}[1]{\xdef\val{#1}\pgfmathsetmacro\vval{#1+60}\begin{tikzpicture}
\Vertex{a}
\path[->] (a) edge [out=\val,in=\vval,looseness=9] (a);
\end{tikzpicture}}

\begin{document}
\tp{0}

\tp{90}

\tp{180}

\tp{270}
\end{document}


I just found here: How do you make a tkz graph with edges starting and ending at the same vertex? that \Loop command takes strange arguments for direction (see dir option) and may be this breaks the behavior. We can also do other thinks using calculations if this is not problem for you. But I think you can see now what is the problem.

• Thank you. However, I am more interested in knowing why the behaviour occurs, or whether I am doing something wrong than in solving the problem. Sorry for not being clear from the start. – ASdeL Aug 31 '17 at 14:27
• Yes. This is my last sentence. (Because I got that in my mind by your question)...[So:Off comment (for anyone interested): For better solution than this I gave I could define a macro giving back the strings NW NE etc]. Welcome – koleygr Aug 31 '17 at 14:30
• I thought I had explain that you have to mention the starting point of the Loop... It remains the same point at all the Loops... and this is what breaks the image's appearance. – koleygr Aug 31 '17 at 14:41
• Yes, that is the problem. But, why the starting point does not rotate together with the rest of the picture? The actual behaviour is not what I would have expected. – ASdeL Aug 31 '17 at 14:48