# Tikz: how to draw closed paths into an ellipse?

I want to draw this kind of graph:

I would like to know how to draw these kind of oriented closed paths into the ellipse. I tried to do this but it was not very beautiful...

\documentclass[10.5pt,a4paper]{article}
\usepackage{tikz}

\begin{document}

\begin{center}
\begin{tikzpicture}

\draw (0,0) ellipse (45mm and 15mm);

\node at (0,1){$\textbf{.}$};
\node at (-3,0){$\textcolor{red}{\infty}$};
\node at (-1,0){$\textcolor{red}{0}$};
\node at (1,0){$\textcolor{red}{t}$};
\node at (3,0){$\textcolor{red}{1}$};

\draw[red] (-3,-0.3) circle (0.07);
\draw[red] (-1,-0.3) circle (0.07);
\draw[red] (1,-0.3) circle (0.07);
\draw[red] (3,-0.3) circle (0.07);

\draw (0,1)--(-2.75,0);
\draw (-2.75,-0.5) arc (140:-140:-0.3) ;
\draw (-2.75,-0.5)--(0,1);

\end{tikzpicture}
\end{center}

\end{document}


which gave me

Is there an easy way to draw these closed paths?

• If you say \draw (a) -- (b) -- (c) -- cycle; the path will be closed. If you say \draw (a) -- (b); then \draw (b) -- (c); etc., it will not. Try drawing the path as one instead of doing it in pieces. – cfr Jul 13 '15 at 23:57

Using the powerful and fast /.pic construct:

Drawing curves using control points in TikZ is too hard (IMO) and involves many trial and errors (See this question referred by @cfr, for example). So, a more practical way is to draw a single picture carefully, then reuse it wherever you want with any scaling, rotation, ...etc. like a normal node.

Here is the definition of the main picture of the whole figure:

[mylobe/.pic = {%
\begin{scope}[xscale=.5]
\coordinate (A) at (0,0);
\coordinate (B) at (0,5);
\draw (A)to[out=65,in=0](B);
\draw[postaction={decorate}] (A)to[out=125,in=-180](B);
\end{scope}
}
]


This is used in drawing the four lobes at different (symmetric) scalings and rotations. Also, the main ellipse is drawn here as a node rather than a normal shape for easy positioning of text nodeas done in the last four lines of the code.

\documentclass[border=1pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,decorations.markings}
\begin{document}

\begin{tikzpicture}[mylobe/.pic = {\begin{scope}[xscale=.5]
\path (0,0) coordinate(A) (0,5) coordinate(B);
\draw[postaction={decorate}] (A)to[out=65,in=0](B) to[out=180,in=115](A);
\end{scope}},%
decoration={markings,mark=at position 0.75 with {\arrow{>}}},
>=latex,%
]

\node(ell) [draw,ellipse, minimum height=30mm, minimum width=90mm]at (0,0){};

\node at (0,1){$\textbf{.}$};
\node at (-3,0){$\textcolor{red}{\infty}$};
\node at (-1,0){$\textcolor{red}{0}$};
\node at (1,0){$\textcolor{red}{t}$};
\node at (3,0){$\textcolor{red}{1}$};

\draw[red] (-3,-0.3) circle (0.07);
\draw[red] (-1,-0.3) circle (0.07);
\draw[red] (1,-0.3) circle (0.07);
\draw[red] (3,-0.3) circle (0.07);

\draw pic at (0,1)[rotate=110,scale=.75 ] {mylobe};
\draw pic at (0,1)[rotate=140,scale=.55 ] {mylobe};
\draw pic at (0,1)[rotate=-140,scale=.55] {mylobe};
\draw pic at (0,1)[rotate=-110,scale=.75] {mylobe};

\node at(ell.190)[above right]{$\gamma_\infty$};
\node at(ell.230)[above]{$\gamma_0$};
\node at(ell.310)[above]{$\gamma_t$};
\node at(ell.350)[above left]{$\gamma_1$};

\end{tikzpicture}

\end{document}


It should be noted that my solution can play well with that of @GonzaloMedina, in which one can draw the main lobe picture mylobe/.pic using the method of control points, thus cutting about 75% of the effort compared to not using a /.pic.

• Thanks a lot, it will be also very useful if I want to draw more complicated graphs! – Julien Roussillon Jul 14 '15 at 12:49

One option using .. controls .. and a decoration for the arrows:

The code:

\documentclass[10.5pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{center}
\begin{tikzpicture}[
decoration={
markings,
mark=at position 0.75 with {\arrow{>}}
},
mycircle/.style={
draw=red!80!black,
circle,
inner sep=1.5pt,
label distance=30pt,
},
>=latex
]

\draw (0,0) ellipse (45mm and 15mm);

\draw[postaction={decorate}]
(0mm,10mm)
.. controls (-60mm,5mm) and (-35mm,-15mm) ..
(0mm,10mm)
node[pos=0.5,below] {$\gamma_\infty$};
\node[mycircle,label={[label distance=-3pt]45:$\infty$}] at (-3,0) {};

\draw[postaction={decorate}]
(0mm,10mm)
.. controls (-28mm,-10mm) and (-8mm,-25mm) ..
(0mm,10mm)
node[pos=0.5,left] {$\gamma_0$};
\node[mycircle,label={[label distance=-3pt]45:$0$}] at (-0.7,0) {};

\draw[postaction={decorate}]
(0mm,10mm)
.. controls (3mm,-18mm) and (35mm,-15mm) ..
(0mm,10mm)
node[pos=0.5,below left] {$\gamma_t$};
\node[mycircle,label={[label distance=-3pt]120:$t$}] at (0.7,0) {};

\draw[postaction={decorate}]
(0mm,10mm)
.. controls (35mm,-15mm) and (60mm,5mm) ..
(0mm,10mm)
node[pos=0.5,above right] {$\gamma_1$};
\node[mycircle,label={[label distance=-3pt]120:$1$}] at (3,0) {};

\end{tikzpicture}
\end{center}

\end{document}

• This is the code which made me finally ask this. – cfr Jul 14 '15 at 1:05