使用文本块逐步生成 tikzpicture

使用文本块逐步生成 tikzpicture

我想构建一个块方案来可视化工作流程。我创建了一个包含逐个出现的节点的 tikzpicture。到目前为止,这很有效。

现在我想为每一步添加插图和公式。它们应该与相应的树项一起出现在工作流树的左右两侧。

请参阅 MWE 了解更多信息。我的问题是各种文本块的出现顺序混乱了。

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes,calc}
\usepackage{pgfplots}
\usepackage[absolute,overlay]{textpos}

\usetheme{Singapore}

\newlength\figureheight
\newlength\figurewidth

\begin{document}

\begin{frame}
  \frametitle{Fundamentals}
  \framesubtitle{X-ray CT imaging statistics}

  % This should appear with 'generation'
  \begin{textblock*}{5cm}(0cm,2.5cm)
    \setlength\figurewidth{5cm}
    \setlength\figureheight{3cm}
    % created this with matplotlib2tikz
    \input{poisson_distribution.tex}
  \end{textblock*}

  \begin{center}
    \begin{tikzpicture}[node distance=5mm, >=latex',
        block/.style = {draw, rectangle, minimum height=10mm, minimum width=28mm,align=center},]
      \node [block] (generation) {Generation};
      \pause
      \node [block, below=of generation] (interaction) {Interaction\\with matter};
      \draw[->] (generation) edge (interaction);
      \pause
      \node [block, below=of interaction] (detection) {Detection};
      \draw[->] (interaction) edge (detection);
      \pause
      \node [block, below=of detection] (processing) {Processing};
      \draw[->] (detection) edge (processing);
    \end{tikzpicture}
  \end{center}

  % This should appear with 'interaction'
  \begin{textblock*}{5cm}(8cm,4.5cm)
    \visible<2->{
      $ \rho_i(\mu) = \exp \left( -\int_L \mu_i(x)\ dx \right) $
    }
  \end{textblock*}
\end{frame}

\end{document}

输入poisson_distribution.tex

\begin{tikzpicture}

\draw[draw=white,fill=lightgray] (axis cs:0,0) rectangle (axis cs:1,1);
\begin{axis}[
xmin=0, xmax=35,
ymin=0, ymax=1200,
axis on top,
width=\figurewidth,
height=\figureheight,
ticklabel style={font=\tiny}
]
\draw[draw=black,fill=blue] (axis cs:3,0) rectangle (axis cs:4,2);
\draw[draw=black,fill=blue] (axis cs:4,0) rectangle (axis cs:5,5);
\draw[draw=black,fill=blue] (axis cs:5,0) rectangle (axis cs:6,18);
\draw[draw=black,fill=blue] (axis cs:6,0) rectangle (axis cs:7,62);
\draw[draw=black,fill=blue] (axis cs:7,0) rectangle (axis cs:8,138);
\draw[draw=black,fill=blue] (axis cs:8,0) rectangle (axis cs:9,200);
\draw[draw=black,fill=blue] (axis cs:9,0) rectangle (axis cs:10,314);
\draw[draw=black,fill=blue] (axis cs:10,0) rectangle (axis cs:11,471);
\draw[draw=black,fill=blue] (axis cs:11,0) rectangle (axis cs:12,697);
\draw[draw=black,fill=blue] (axis cs:12,0) rectangle (axis cs:13,864);
\draw[draw=black,fill=blue] (axis cs:13,0) rectangle (axis cs:14,945);
\draw[draw=black,fill=blue] (axis cs:14,0) rectangle (axis cs:15,966);
\draw[draw=black,fill=blue] (axis cs:15,0) rectangle (axis cs:16,1014);
\draw[draw=black,fill=blue] (axis cs:16,0) rectangle (axis cs:17,911);
\draw[draw=black,fill=blue] (axis cs:17,0) rectangle (axis cs:18,838);
\draw[draw=black,fill=blue] (axis cs:18,0) rectangle (axis cs:19,693);
\draw[draw=black,fill=blue] (axis cs:19,0) rectangle (axis cs:20,591);
\draw[draw=black,fill=blue] (axis cs:20,0) rectangle (axis cs:21,414);
\draw[draw=black,fill=blue] (axis cs:21,0) rectangle (axis cs:22,323);
\draw[draw=black,fill=blue] (axis cs:22,0) rectangle (axis cs:23,213);
\draw[draw=black,fill=blue] (axis cs:23,0) rectangle (axis cs:24,134);
\draw[draw=black,fill=blue] (axis cs:24,0) rectangle (axis cs:25,69);
\draw[draw=black,fill=blue] (axis cs:25,0) rectangle (axis cs:26,58);
\draw[draw=black,fill=blue] (axis cs:26,0) rectangle (axis cs:27,32);
\draw[draw=black,fill=blue] (axis cs:27,0) rectangle (axis cs:28,16);
\draw[draw=black,fill=blue] (axis cs:28,0) rectangle (axis cs:29,5);
\draw[draw=black,fill=blue] (axis cs:29,0) rectangle (axis cs:30,4);
\draw[draw=black,fill=blue] (axis cs:30,0) rectangle (axis cs:31,3);
\draw[fill=white,draw opacity=0] (axis cs:0,0) rectangle (axis cs:1,1);
\end{axis}

\end{tikzpicture}

感谢你的帮助!

答案1

我认为你把这个弄得太复杂了。除了 s textblock,你还可以使用列,poisson_distribution在第一个列中添加 ,在第二个列中添加流程图。要使方程式与图表相应部分同时出现,只需将其作为 添加label到该节点即可。

\documentclass{beamer}

\usepackage{pgfplots}
\usetikzlibrary{arrows,positioning,shapes,calc}
\usepackage[absolute,overlay]{textpos}

\usetheme{Singapore}

\newlength\figureheight
\newlength\figurewidth

\begin{document}

\begin{frame}
  \frametitle{Fundamentals}
  \framesubtitle{X-ray CT imaging statistics}

\begin{columns}[T]
\begin{column}{4.5cm}
    \setlength\figurewidth{5cm}
    \setlength\figureheight{3cm}
    % created this with matplotlib2tikz
    \input{poisson_distribution.tex}
\end{column}
\begin{column}{7.5cm}
    \begin{tikzpicture}[node distance=5mm, >=latex',
        block/.style = {draw, rectangle, minimum height=10mm, minimum width=28mm,align=center},]
      \node [block] (generation) {Generation};
      \pause
      \node [block, below=of generation,
       label=right:{$\rho_i(\mu) = \exp \left( -\int_L \mu_i(x)\ dx \right)$}] (interaction) {Interaction\\with matter};
      \draw[->] (generation) edge (interaction);
      \pause
      \node [block, below=of interaction] (detection) {Detection};
      \draw[->] (interaction) edge (detection);
      \pause
      \node [block, below=of detection] (processing) {Processing};
      \draw[->] (detection) edge (processing);
    \end{tikzpicture}
  \end{column}
\end{columns}
\end{frame}

在此处输入图片描述

相关内容