我正在尝试使用 连接 3d 图内的两个坐标(节点)pgfplots
。我面临的问题是连接线甚至没有接触端点。我猜这条线被投影到某个平面上,但我该如何解决这个问题?
这是 MWE,其中洋红色的线说明了问题:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}
% s(t) curve
\addplot3 [
mesh,
color=blue,
domain=-0.7:0.7
] (x, x, -{2/5}*x^2);
% dots on s(t)
\addplot3 [
color=blue,
draw=none,
mark=*,
mark size=1.5
] table [row sep=crcr] {%
0 0 0 \\
} node (S) [at start,above] {$s(t)$};
% r(t)
\addplot3 [
mesh,
color=blue,
domain=-0.7:0.707
] (x, {0.5*(5*0.3-(-4*x^2+20*0.2-20*x*0.3+25*0.3^2)^0.5)}, {-0.2+0.5*0.3*(2*x-5*0.3+(-4*x^2+20*0.2-20*x*0.3+25*0.3^2)^0.5)});
% dots on r(t)
\addplot3 [
color=blue,
draw=none,
mark=*,
mark size=1.5
] table [row sep=crcr] {%
0 -0.5 -0.05\\
} node (R) [at start,below] {$r(t)$};
\draw[thick,magenta] (R) -- (S);
\end{axis}
\end{tikzpicture}
\end{document}
答案1
为什么要连接节点?您应该通过坐标进行连接。因为正如您所指定的,节点实际上位于坐标的上方和下方(node (S) [at start,above] {$s(t)$}
和node (R) [at start,below] {$r(t)$}
):
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}
% s(t) curve
\addplot3 [
mesh,
color=blue,
domain=-0.7:0.7
] (x, x, -{2/5}*x^2);
% dots on s(t)
\addplot3 [
color=blue,
draw=none,
mark=*,
mark size=1.5
] table [row sep=crcr] {%
0 0 0 \\
} node (S) [at start,above] {$s(t)$};
% r(t)
\addplot3 [
mesh,
color=blue,
domain=-0.7:0.707
] (x, {0.5*(5*0.3-(-4*x^2+20*0.2-20*x*0.3+25*0.3^2)^0.5)}, {-0.2+0.5*0.3*(2*x-5*0.3+(-4*x^2+20*0.2-20*x*0.3+25*0.3^2)^0.5)});
% dots on r(t)
\addplot3 [
color=blue,
draw=none,
mark=*,
mark size=1.5
] table [row sep=crcr] {%
0 -0.5 -0.05\\
} node (R) [at start,below] {$r(t)$};
\draw[thick,magenta] (0,0,0) -- (0,-0.5,-0.05);
\end{axis}
\end{tikzpicture}
\end{document}