Tikz:如何将封闭的路径绘制成椭圆?

Tikz:如何将封闭的路径绘制成椭圆?

我想要绘制这种图形:在此处输入图片描述

我想知道如何在椭圆中绘制这种定向闭合路径。我试过这样做,但效果不太美观……

\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}

这给了我

在此处输入图片描述

有没有简单的方法来绘制这些封闭的路径?

答案1

使用强大而快速的/.pic构造:

在此处输入图片描述

在 TikZ 中使用控制点绘制曲线太难了(在我看来),需要反复试验(参见这个问题例如由@cfr 提及的)。因此,更实用的方法是仔细绘制一张图,然后像普通节点一样在任何地方以任何缩放、旋转等方式重复使用它。

下面是整幅图主图的定义:

[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}
         }
]

这用于以不同的(对称)缩放和旋转绘制四个叶瓣。此外,主椭圆在此处绘制为节点而不是正常形状,以便于定位文本节点,如代码的最后四行所示。

\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}

值得注意的是,我的解决方案可以与@GonzaloMedina 的解决方案很好地配合使用,其中可以mylobe/.pic使用控制点的方法绘制主瓣图,因此与不使用相比可以减少约 75% 的工作量/.pic

答案2

一个选项是使用.. controls ..和箭头的装饰:

在此处输入图片描述

代码:

\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);

\fill (0mm,10mm) circle [radius=1.5pt];

\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}

相关内容