在单位单纯形上绘制路径

在单位单纯形上绘制路径

我正在尝试模拟单位单纯形上的路径,可以使用以下命令绘制pgfplots

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{130}
\begin{tikzpicture}[tdplot_main_coords]
  \def\laxis{5}
  \def\ltriangle{3}
  \begin{scope}[->,red]
    \draw (0,0,0) -- (\laxis,0,0) node [below] {\textcolor{blue}{$x$}};
    \draw (0,0,0) -- (0,\laxis,0) node [right] {\textcolor{blue}{$y$}};
    \draw (0,0,0) -- (0,0,\laxis) node [left] {\textcolor{blue}{$z$}};
  \end{scope}
  \filldraw [opacity=.5,green] (\ltriangle,0,0) -- (0,\ltriangle,0) --
  (0,0,\ltriangle) -- cycle;
\end{tikzpicture}
\end{document}

我画了一个大概的轮廓:

在此处输入图片描述

其中角的坐标为 (1,0,0) (0,1,0) (0,0,1)。页面只是一组随机坐标,元素加起来为 1,我想将坐标输入程序中来绘制单纯形上的路径,但我不太确定如何做到这一点。

6 个时间步长的路径示例:

(0.25,0.5,0.25) , (0.2,0.6,0.2), (0.24,0.56,0.2), (0.16,0.52,0.0.32),(0.12,0.5,0.38), (0.1,0.46,0.44)

答案1

您可以使用pgfplots

在此处输入图片描述

代码:

\documentclass[border=3pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
  view/h=134.5,
  axis lines=center,
  xmax=1.5, 
  ymax=1.5,
  zmax=1.5,
  ytick={1},
  xlabel={$X_{1}$},
  ylabel={$X_{2}$},
  zlabel={$X_{3}$},
]
\addplot3[patch,green!70!black!50,forget plot] 
  coordinates 
  {
  (1,0,0) 
  (0,1,0) 
  (0,0,1)
  };
\addplot3[no markers,red!90!black] 
  coordinates 
  { 
  (0.25,0.1,0.45) 
  (0.2,0.1,0.4) 
  (0.24,0.36,0.4) 
  (0.16,0.32,0.62) 
  (0.12,0.3,0.58) 
  (0.1,0.26,0.64) 
  };
\addplot3[no markers,blue] 
  coordinates 
  { 
  (0.25,0.5,0.25) 
  (0.2,0.6,0.2) 
  (0.24,0.56,0.2) 
  (0.16,0.52,0.32) 
  (0.12,0.5,0.38) 
  (0.1,0.46,0.44) 
  };
\legend{$Y$,$Z$};
\node[fill=blue,inner sep=1pt,circle,label={180:$Z$}] 
  at (axis cs:0.25,0.5,0.25) {};  
\node[fill=red!90!black,inner sep=1pt,circle,label={180:$Y$}] 
  at (axis cs:0.1,0.26,0.64) {};  
\end{axis}
\end{tikzpicture}

\end{document}

相关内容