我尝试绘制一条自定义曲线,该曲线由沿 x 轴自我重现的图案组成。因此,我定义了一个具有 4 个节点 (P0-P3) 的图案,并想使用新节点复制/粘贴该图案。问题是,每个图案之间都有一个我想填充的空白。我尝试在节点内画线,但不是很平滑。
任何想法?
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}[scale = 0.5]
\node[] (P0) at (0,1){};
\node[] (P1) at (2,2){};
\node[] (P2) at (5,-4){};
\node[] (P3) at (7,1){};
\node[] (P3b) at (7-0.1,1-0.05){};
\node[] (P4) at (9,2){};
\node[] (P5) at (12,-4.5){};
\node[] (P6) at (14,1){};
\node[] (P7) at (16,2){};
\node[] (P8) at (19,-4.5){};
\node[] (P9) at (21,1){};
\draw[line width = 8pt]
(P0.north east) .. controls (P1.north east) and (P2.north east) ..
(P3.south);
\draw[line width = 8pt]
(P3b.north east) .. controls (P4.north east) and (P5.north east) ..
(P6.center);
\draw[line width = 8pt]
(P6.north east) .. controls (P7.north east) and (P8.north east) ..
(P9.center);
\draw[line width = 8pt] (P3b.south) edge[] (P3.north east);
\end{tikzpicture}
\end{figure}
\end{document}
顺便说一句,我也尝试过只用一条曲线来绘制它,但我不知道如何计算节点坐标,这样我就能得到完全相同的图案。
万分感谢
答案1
看起来你正在追求这样的事情:
你不是画一个图案,而是画一条由三段组成的线。这可以通过定义线段的起点和终点的坐标来实现:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}[scale = 0.5]
\coordinate (P0) at (0,1);
\coordinate (P1) at (2,2);
\coordinate (P2) at (5,-4);
\coordinate (P3) at (7,1);
\coordinate (P4) at (9,2);
\coordinate (P5) at (12,-4.5);
\coordinate (P6) at (14,1);
\coordinate (P7) at (16,2);
\coordinate (P8) at (19,-4.5);
\coordinate (P9) at (21,1);
\draw[line width = 8pt]
(P0) .. controls (P1) and (P2) .. (P3)
.. controls (P4) and (P5) .. (P6)
.. controls (P7) and (P8) .. (P9);
\end{tikzpicture}
\end{figure}
\end{document}