绘制非单连通域

绘制非单连通域

有人可以帮我画一些类似这样的图吗?

在此处输入图片描述

它应该是曲线 C 内的复杂域,而不是简单连接(C_1 和 C_2 内有两条曲线)并沿曲线有箭头。

我的尝试:

\documentclass[12pt, letterpaper,twoside]{article}
\usepackage{tikz}

\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{quotes,angles}
\usetikzlibrary{positioning}
\usetikzlibrary{patterns} 
\usetikzlibrary{chains}
\usetikzlibrary{hobby}
\tikzset{
    arc arrow/.style args={%
    to pos #1 with length #2}{
    decoration={
        markings,
         mark=at position 0 with {\pgfextra{%
         \pgfmathsetmacro{\tmpArrowTime}{#2/(\pgfdecoratedpathlength)}
         \xdef\tmpArrowTime{\tmpArrowTime}}},
        mark=at position {#1-\tmpArrowTime} with {\coordinate(@1);},
        mark=at position {#1-2*\tmpArrowTime/3} with {\coordinate(@2);},
        mark=at position {#1-\tmpArrowTime/3} with {\coordinate(@3);},
        mark=at position {#1} with {\coordinate(@4);
        \draw[-{Stealth[length=#2,bend]}]       
        (@1) .. controls (@2) and (@3) .. (@4);},
        },
     postaction=decorate,
     }
}

\begin{document}
\begin{tikzpicture}

\draw[thick, ->] (-1,0) -- (7,0) node[right]{$x$};
\draw[thick, ->] (0,-0.5) -- (0,6) node[left]{$y$};

\coordinate (N) at (1.1,4.9);
\coordinate (O) at (1.7,5.3);
\coordinate (P) at (3,4.5);
\coordinate (Q) at (3.5,3);
\coordinate (A) at (5.2,2.6);
\coordinate (R) at (6,2);
\coordinate (B) at (5.3,0.5);
\coordinate (S) at (3.5,0.5);
\coordinate (T) at (2,2);
\coordinate (U) at (1,3.5);

\draw[fill=lightgray] (N) to [pattern=north east lines, closed, curve through = {(N) (O)  (P)  (Q) (A) (R) (B) (S) (T) (U)}] (N);

\fill[white] (4.5,1.5) circle (0.75cm);
\draw[black,fill=white] (4.5,1.5) circle (0.75cm);

\begin{scope}
    \draw[arc arrow=to pos 1 with length 3mm] (O) to[out=186,in=228] (N);
    \draw[arc arrow=to pos 1 with length 3mm] (U) to[out=295,in=125] (T);
    \draw[arc arrow=to pos 1 with length 3mm] (S) to[out=336,in=205] (B);
    \draw[arc arrow=to pos 0.5 with length 3mm] (A) to[out=168,in=319] (Q);
\end{scope}

\coordinate (J) at (2,4.5);
\coordinate (K) at (2.5,4);
\coordinate (L) at (2,3.5);
\coordinate (M) at (1.5,4);

\filldraw (J) circle (1pt);
\filldraw (K) circle (1pt);
\filldraw (L) circle (1pt);
\filldraw (M) circle (1pt);

\draw[fill=white] (J) to [out angle=0, in angle=180, curve through = {(J) (K)  (L)  (M)}] (J);

\end{tikzpicture}
\end{document}

谢谢!!

答案1

你把这个搞得太复杂了。用一个\draw命令绘制所有三条封闭曲线,使用even odd rule填充曲线之间的区域。用箭头装饰装饰中使用的标签。命令的最后\node应该只有一个,但您还需要在标记内的命令后面使用 s 。这里是基本思想:;\draw;\node

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}
\draw[thick, fill=lightgray, even odd rule, postaction={decorate},
    decoration={markings, mark=at position .15 with {\arrow{latex}\node[above right]{$C$};},
    mark=at position .65 with {\arrow{latex}\node[above right]{$C_1$};},
    mark=at position .85 with {\arrow{latex}\node[above right]{$C_2$};}}] 
    (0,0) circle[radius=3] 
    (1.5,0) circle[radius=1]
    (-1.5,0) circle[radius=1];
\end{tikzpicture}

\end{document}

同样的原理也适用于更复杂的曲线。您可以通过将箭头添加到命令中添加任意数量的箭头(带标签或不带标签)draw。请记住,路径由所有三条曲线组成,因此pos=将从外曲线(或您先绘制的曲线)开始,并在最后一条曲线上结束。

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}

\draw[thick, ->] (-1,0) -- (7,0) node[right]{$x$};
\draw[thick, ->] (0,-0.5) -- (0,6) node[left]{$y$};

\coordinate (N) at (1.1,4.9);
\coordinate (O) at (1.7,5.3);
\coordinate (P) at (3,4.5);
\coordinate (Q) at (3.5,3);
\coordinate (A) at (5.2,2.6);
\coordinate (R) at (6,2);
\coordinate (B) at (5.3,0.5);
\coordinate (S) at (3.5,0.5);
\coordinate (T) at (2,2);
\coordinate (U) at (1,3.5);

\coordinate (J) at (2,4.5);
\coordinate (K) at (2.5,4);
\coordinate (L) at (2,3.5);
\coordinate (M) at (1.5,4);

\draw[thick, fill=lightgray, even odd rule, postaction={decorate}, decoration={markings, 
    mark=at position .35 with {\arrow{latex}\node[above right]{$C$};},
    mark=at position .7 with {\arrow{latex}\node[above right=-3pt]{$C_1$};},
    mark=at position .92 with {\arrow{latex}\node[above right=-3pt]{$C_2$};}}] 
    plot[smooth cycle] coordinates{(U)(T)(S)(B)(R)(A)(Q)(P)(O)(N)}
    (4.5,1.5) circle (0.75cm)
    plot[smooth cycle] coordinates {(M)(L)(K)(J)};

\end{tikzpicture}
\end{document}

相关内容