2

Why do i not get a loop at the middle up node in the following graph?

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \coordinate (1) at (0,0) ;
    \coordinate (2) at (0,-1);
    \coordinate (3) at (-1,0);
    \coordinate (4) at (-1,-1);
    \coordinate (5) at (1,0);
    \coordinate (6) at (1,-1);

    % ============================================
    % loop here:
    \draw (1) to[out=40,in=140,looseness=8] (1) ;
    % ============================================
    \draw (1) to[out=150,in=30] (3) ;
    \draw (1) to[out=210,in=-30] (3) ;
    \draw (5) to[out=150,in=30] (1) ;
    \draw (5) to[out=210,in=-30] (1) ;

    \draw (3) -- (4) ;
    \draw (1) -- (2) ;
    \draw (5) -- (6) ;
    \draw (4) -- (2) ;
    \draw (2) -- (6) ;
    \foreach \x in {(1), (2), (3), (4), (5), (6)}{
        \fill \x circle[radius=2pt];
    }
\end{tikzpicture}
\end{document}

Result:

enter image description here

I tried to add a coordinate (1p) slight different then (1) as in Tikz arrows on loops not showing up ; but it does not work. I already noticed differences between node and coordinate; maybe this is also connected to a different behavior.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \coordinate (1) at (0,0) ;
    \coordinate (1p) at (0,0.1) ;
    \coordinate (2) at (0,-1);
    \coordinate (3) at (-1,0);
    \coordinate (4) at (-1,-1);
    \coordinate (5) at (1,0);
    \coordinate (6) at (1,-1);

    \draw (1) to[out=150,in=30] (3) ;
    \draw (1) to[out=210,in=-30] (3) ;
    \draw (5) to[out=150,in=30] (1) ;
    \draw (5) to[out=210,in=-30] (1) ;
    \draw (1) to[out=40,in=140,looseness=8] (1p) ;

    \draw (3) -- (4) ;
    \draw (1) -- (2) ;
    \draw (5) -- (6) ;
    \draw (4) -- (2) ;
    \draw (2) -- (6) ;
    \foreach \x in {(1), (2), (3), (4), (5), (6)}{
        \fill \x circle[radius=2pt];
    }
\end{tikzpicture}
\end{document}

Result:

enter image description here

Orrible!

4

Add loop option to draw.

\draw (1) to[out=40,in=140,looseness=8,loop] (1) ;

enter image description here

  • oh my god! I tried it, BUT if you put it in front of looseness it does not work, incredible. – PeptideChain Jun 28 at 10:01
  • You are right, and looseness parameter is suppressing by loop. Changing it's values are not affecting the loop shape. – ferahfeza Jun 28 at 12:39
5

This is an extended comment. The looseness key requires the start and end point of the loop to differ in order to be appreciated. So if one replaces your point coordinate by a node with some nontrivial dimensions, the looseness key works as expected.

\documentclass[tikz,border=3.14mm]{standalone}

\begin{document}
\foreach \X in {3,4,...,32,31,30,...,4}
{\begin{tikzpicture}
    \path[use as bounding box] (-1.1,-1.1) rectangle (1.1,1.2);
    \coordinate (1) at (0,0)  ;
    \coordinate (2) at (0,-1);
    \coordinate (3) at (-1,0);
    \coordinate (4) at (-1,-1);
    \coordinate (5) at (1,0);
    \coordinate (6) at (1,-1);

    % ============================================
    % loop here:
    \node[inner sep=2pt] (aux) at (1) {}edge[out=60,in=120,loop,looseness=\X] (aux);
    %\draw (1) edge[out=40,in=140,loop,looseness=12] (1);
    % ============================================
    \draw (1) to[out=150,in=30] (3) ;
    \draw (1) to[out=210,in=-30] (3) ;
    \draw (5) to[out=150,in=30] (1) ;
    \draw (5) to[out=210,in=-30] (1) ;

    \draw (3) -- (4) ;
    \draw (1) -- (2) ;
    \draw (5) -- (6) ;
    \draw (4) -- (2) ;
    \draw (2) -- (6) ;
    \foreach \x in {(1), (2), (3), (4), (5), (6)}{
        \fill \x circle[radius=2pt];
    }
\end{tikzpicture}}
\end{document}

enter image description here

So the overall recommendation is to make the nodes extended objects, which also helps to shorten the code.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[bullet/.style={circle,fill,inner sep=2pt},nodes=bullet]
    \draw (0,0) node (1){} --(0,-1) node (2){} 
    (-1,0) node (3){} -- (-1,-1) node (4){} 
    (1,0) node (5){} -- (1,-1) node (6){} 
    (1)  edge[out=150,in=30] (3) (3)  edge[out=-30,in=-150] (1)
    (1)  edge[out=-30,in=-150] (5) (5)  edge[out=150,in=30] (1)
    (2) -- (4) -- (6)
    (1) to[out=40,in=140,looseness=18] (1);
\end{tikzpicture}
\end{document}

enter image description here

  • Thank you for extended comment, +1. – ferahfeza Jun 28 at 18:26
  • thank you. I've to revise all my graphs. fortunately are still less than 10 – PeptideChain Jun 29 at 12:53
  • about your last example: you do not specify the radius of the circle. what is the default? how to I specify it in the head: the two most intuitive (to me) variants do not work – PeptideChain Jun 29 at 13:18
  • @PeptideChain Sorry, I do not understand your comment. The size of the bullet is controlled by inner sep=2pt. – user121799 Jun 29 at 14:10
  • thank you for your reply. I open a new question and post the link here – PeptideChain Jun 29 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.