TikZ 开集土豆链

TikZ 开集土豆链

我必须画出一个开集土豆链,类似于这张图片中的东西 在此处输入图片描述

我尝试了几个\draw plot [smooth cycle] coordinates { (0.7,1.4) (2,0.8) (1.5,-0.5) (0.8,-1) (-0.2,-0.8) (-0.4,0)};,但那样的话我就得一个土豆一个土豆地做。

有没有办法可以更快地绘制这样的东西?

答案1

您可以按照\draw plot [smooth cycle]您建议的方式执行此操作,但使用循环中的参数更改坐标:

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}

\tikzset{big square/.style={draw, thick, minimum size=1.5cm},
    line 0/.style={thick},
    line 1/.style={dash pattern=on 8pt off 3pt, thick}
}

\begin{document}

\begin{tikzpicture}
\node[draw, thick, rounded corners=1cm, minimum height=7.5cm, minimum width=12cm, label={[label distance=-6mm]south east:$X$}]{};
\path(-3,0)node[big square]{$A$}--(3,0)node[big square]{$B$};
\foreach \t[evaluate=\t as \s using {\t==5}] in {1,...,8}{
    \draw[line \s] plot [smooth cycle, tension=.8] coordinates { (-3.75-.2*\t,.25+.05*\t) (-3.7-.1*\t,-1-.1*\t) (-2+.2*\t,-0.55-.2*\t) (-2+.3*\t,.05*\t) (-2.8+.95*\t,1.3+.1*\t) (-3.4,.8+.3*\t)};
    \node at (-2.8+.95*\t,1.3+.1*\t)(p\t){};
}
\node[right] at (p1){$u_0$};
\node[right] at (p2){$u_{\frac{1}{5}}$};
\node[right] at (p3){$u_{\frac{1}{4}}$};
\node[right] at (p4){$u_{\frac{1}{3}}$};
\node[right] at (p6){$u_{\frac{1}{2}}$};
\node[right] at (p7){$u_{\frac{2}{3}}$};
\node[right] at (p8){$u_{\frac{3}{4}}$};
\coordinate (p5) at (-.5,.25);
\node at (1,-1)(p0){$u_{\frac{2}{5}}$};
\draw[semithick, -latex] (p0) to[out=150, in=-30] (p5);

\end{tikzpicture}

\end{document}

答案2

以下是一个尝试元帖子您可能想尝试一下它作为替代绘图语言。

在此处输入图片描述

它被包装在内luamplib,因此您需要用 来编译它lualatex

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
    path A, B, X, arc;

    A = unitsquare scaled 30;
    B = A shifted 160 right;
    arc = point 2 of A  {dir 40}..  point 2 of B shifted (20, 90);

    draw A; draw B;

    numeric d[]; 
    path u[];
    for i=1 upto 8:
        for j = 1 upto 16:
            d[j] := if known d[j]: d[j] else: 1 fi + 1/2 + uniformdeviate 1/2 ;
        endfor
        u[i] = for j = 1 upto 16:
            if (j = 5) or (j = 6):
                (i/9)[point 1/8 + 1/4 j of A, point 1/8 + 1/4(20-j) of B]
            elseif j=7:
                point i/8 of arc 
            else:
                (d[j])[center A, point 1/8 + 1/4 j of A] 
            fi ..
        endfor cycle;
        draw u[i] if i=5: dashed evenly scaled 2 fi;
    endfor

    label("$A$", center A);
    label("$B$", center B);
    interim labeloffset := 1;
    label.urt("$u_0$", point 6 of u1);
    label.urt("$u_{\frac15}$", point 6 of u2);
    label.urt("$u_{\frac14}$", point 6 of u3);
    label.urt("$u_{\frac13}$", point 6 of u4);
    label.urt("$u_{\frac12}$", point 6 of u6);
    label.urt("$u_{\frac23}$", point 6 of u7);
    label.urt("$u_{\frac34}$", point 6 of u8);

    label("$u_1$", point 1 of B shifted (40, -50));
    z1 = point 0 of B shifted (0, -64);
    label.rt("$u_{\frac25}$", z1);
    interim ahangle := 30;
    drawarrow z1 + 2 up {left} .. {dir 150} point 3 of u5 
        cutafter fullcircle scaled 4 shifted point 3 of u5;

    numeric r; r = 1/16;
    interim bboxmargin := 10;
    X = for i=0 upto 3: subpath (i+r, i+1-r) of bbox currentpicture .. endfor cycle;
    draw X;

    label.ulft("$X$", lrcorner bbox currentpicture);

endfig;
\end{mplibcode}
\end{document}

相关内容