我第一次使用 hobby 包,我觉得不支持使用命名节点代替坐标。具体来说,为什么以下 MWE 会产生两张不同的图片?
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid[step=0.25] (1,1);
\draw
(0,0) to [curve through={
(0.15,0.35) ..
(0.5,0.5) ..
(0.8,0.6) } ]
(1,1);
\end{tikzpicture}
\begin{tikzpicture}
\node (n1) at (0,0) {};
\node (n2) at (0.15,0.35){};
\node (n3) at (0.5,0.5){};
\node (n4) at (0.8,0.6){};
\node (n5) at (1,1){};
\draw[help lines] (0,0) grid[step=0.25] (1,1);
\draw
(n1) to [curve through={
(n2) ..
(n3) ..
(n4) } ]
(n5);
\end{tikzpicture}
\end{document}
答案1
节点不是坐标!它们的大小不为零,因此它们之间的线不连续。解决方法有两种:
- 对于命名坐标使用例如
\draw
(n1.center) to [curve through={
(n2.center) ..
(n3.center) ..
(n4.center) } ]
(n5.center);
- 或者将命名坐标定义为
\coordinate (n1) at (0,0);
\coordinate (n2) at (0.15,0.35);
\coordinate (n3) at (0.5,0.5);
\coordinate (n4) at (0.8,0.6);
\coordinate (n5) at (1,1);
在这两种情况下你都会得到相同的结果: