![将多条曲线合并为一条线](https://linux22.com/image/407086/%E5%B0%86%E5%A4%9A%E6%9D%A1%E6%9B%B2%E7%BA%BF%E5%90%88%E5%B9%B6%E4%B8%BA%E4%B8%80%E6%9D%A1%E7%BA%BF.png)
如何用 TikZ 绘制合并为一条线的多条曲线?下面是示例:
我尝试了以下代码,但它看起来非常丑陋:
\draw[] (2.4,5.4) .. controls (2.4,4.2) and (2.8,4.2) .. (7,8.5);
\draw[] (2,7.6) .. controls (1.8,8.6) and(3,8.5) .. (7,8.5);
\draw[] (1.55,7.6) .. controls (1.7,8.6) and(3,8.5) .. (7,8.5);
\draw[] (9.8,4) .. controls (8.5,5) and (8,6) .. (7,8.5);
\draw[] (7,8.5) .. controls (7,12) and (6,13.5) .. (5,13.5);
答案1
欢迎使用 TeX.SE。这种绘图可以通过to
路径操作、其in
和out
选项来完成,以指定有趣点的入射角和出射角,attach arrow
薛定谔的猫的风格还有...一点耐心。
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{decorations.markings, arrows.meta, bending}
% 'attach arrow' style from Schrödinger's cat:
% <https://tex.stackexchange.com/a/524935/73317>
\tikzset{%
attach arrow/.style={
decoration={
markings,
mark=at position 0 with {\pgfextra{%
\pgfmathsetmacro{\tmpArrowTime}{\pgfkeysvalueof{/tikz/arc arrow/length}/(\pgfdecoratedpathlength)}%
\xdef\tmpArrowTime{\tmpArrowTime}}},
mark=at position {#1-3*\tmpArrowTime} with {\coordinate(@1);},
mark=at position {#1-2*\tmpArrowTime} with {\coordinate(@2);},
mark=at position {#1-1*\tmpArrowTime} with {\coordinate(@3);},
mark=at position {#1+\tmpArrowTime/2} with {\coordinate(@4);
\draw[-{Stealth[length=\pgfkeysvalueof{/tikz/arc arrow/length},bend]}]
plot[smooth] coordinates {(@1) (@2) (@3) (@4)};},
},
postaction=decorate,
},
attach arrow/.default=0.5,
arc arrow/length/.initial=2mm,
}
\begin{document}
\begin{tikzpicture}
\draw[attach arrow=0.2, attach arrow=0.83]
(-6,-2) to[out=45, in=180] (-4,-1) to[out=0, in=180] (-1.7,-1.8)
to[out=0, in=-95] (0,0) to[out=85, in=0] (-3,2) to[out=180, in=70] (-5,1);
\draw[attach arrow=0.5] (-6.5,-4) to[out=-30, in=180] (-5.5,-4.2)
to[out=0, in=180] (-3,-3) to[out=0, in=205] (-1.1,-3)
to[out=25, in=-95] (0,0);
\draw[attach arrow=0.3] (-1.5,-8) to[out=110, in=260] (-0.2,-2.5)
to[out=80, in=-95] (0,0);
\end{tikzpicture}
\end{document}