向使用 tikz 创建的图形模型添加方程式

向使用 tikz 创建的图形模型添加方程式

我正在使用 tikz。我有一个图形模型,我想在侧面添加方程式作为解释。就像 这就是我得到的。 这就是我想要的。所以我不想要这样的模型,而是想要旁边的解释方式。

感谢您的帮助!

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit,positioning}
 \usetikzlibrary{ automata}

\begin{document}
\begin{figure}
 \centering

 \begin{tikzpicture}[auto]\label{modelcomplete}

 \tikzstyle{main}=[circle, minimum size = 15mm, thick, draw =black!80, node distance = 16mm]
 \tikzstyle{connect}=[-latex, thick]
 \tikzstyle{box}=[rectangle, draw=black!100]

   \node[main, accepting, fill = white!100] (theta) {$\theta$};
   \node[main] (muA) [left=of theta,xshift = -14mm] { $\mu_A$};
   \node[main] (muB) [right=of theta,xshift = 14mm]{ $\mu_B$};

   \node[main] (dim1) [below left=of theta] {Dim1};
   \node[main] (dim2) [below right=of theta] {Dim2};
   \node[main] (choice) [above=of theta] {choice};
   \node[main] (N) [above=of choice] {N};
   \path (muA) edge [connect] (theta)
         (muB) edge [connect] (theta)
         (choice) edge [connect] (theta)
         (theta) edge [connect] (dim1)
         (N) edge [connect] (choice)
         (theta) edge [connect] (dim2);
  \node[rectangle, inner sep=4mm,draw=black!100, fit= (choice) (theta)(dim1) (dim2),label=below right:N] {};
 \end{tikzpicture}

 \end{figure}
\end{document}

答案1

您可以在另一个文本中写入任何您想要的内容node,并将其放在前一个文本的周围。

举一个可能的例子:

在此处输入图片描述

代码如下:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit,positioning}
 \usetikzlibrary{ automata}
 \usepackage{amsmath}

\begin{document}
\begin{figure}
 \centering

 \begin{tikzpicture}[auto]\label{modelcomplete}

 \tikzstyle{main}=[circle, minimum size = 15mm, thick, draw =black!80, node distance = 16mm]
 \tikzstyle{connect}=[-latex, thick]
 \tikzstyle{box}=[rectangle, draw=black!100]

   \node[main, accepting, fill = white!100] (theta) {$\theta$};
   \node[main] (muA) [left=of theta,xshift = -14mm] { $\mu_A$};
   \node[main] (muB) [right=of theta,xshift = 14mm]{ $\mu_B$};

   \node[main] (dim1) [below left=of theta] {Dim1};
   \node[main] (dim2) [below right=of theta] {Dim2};
   \node[main] (choice) [above=of theta] {choice};
   \node[main] (N) [above=of choice] {N};
   \path (muA) edge [connect] (theta)
         (muB) edge [connect] (theta)
         (choice) edge [connect] (theta)
         (theta) edge [connect] (dim1)
         (N) edge [connect] (choice)
         (theta) edge [connect] (dim2);
  \node[rectangle, inner sep=4mm,draw=black!100, fit= (choice) (theta)(dim1) (dim2),label=below right:N] (box) {};

  \node[text width=5cm, align=left, right=of box.north east ]{$\mu\sim\text{Gaussian}(0,0.001)$\\$\lambda_i\sim\text{Gamma}(0.001,0.001)$\\$\sigma_i\leftarrow 1/\sqrt{\lambda_i}$\\
  $x_i\sim\text{Gaussian}(\mu,\lambda_i)$};
 \end{tikzpicture}

 \end{figure}
\end{document}

相关内容