TikZ 节点定位、不透明度、箭头和绘制控件

TikZ 节点定位、不透明度、箭头和绘制控件

我正在尝试使用 Ti 绘制流程图Z。

我希望箭头中的文字出现在路径的左侧或右侧,而不是箭头上方。我也尝试使用节点不透明度来解决这个问题,style={fill=white}但没有成功。

我还设法按照我想要的方式定位节点,但我相信还有很多更简单的方法可以做到这一点。我看到了库matrix和分层布局之类的东西,但无法成功实现它。

最后,我希望有一个像我在图片中手动绘制的箭头。我尝试使用控件,但结果并不完全符合我的预期,因为箭头穿过了一些节点。

非常感谢您的支持。

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\scalebox{0.6}[0.6]{
    \begin{tikzpicture}
        [>=stealth, place/.style={shape=rectangle,draw,rounded corners,fill=blue!25,},trans/.style={align=center},auto,scale=3]         
        \node[place] (a1) {Input};
        \node[trans,right=2cm of a1] (b1) {Replicate};
        \node[place,right=2.05cm of b1] (c1) {Working};
        \node[below=0.5cm of b1 ,shape=rectangle,draw,rounded corners,fill=red!25,inner sep=4] (a2) {\LARGE \centering Imputation Step Iteration 1};
        \node[place,below=1.75cm of a1] (a3) {Input};
        \node[place,below=1.75cm of c1] (b3) {Working};
        \node[trans,below=0.6cm of a3] (a4) {\footnotesize SSCPMISS};   
        \node[trans,below=0.5cm of b3,] (b4) {Replicate};
        \node[shape=rectangle,draw,rounded corners,fill=blue!25,align=center,below=0.6cm of a4] (a5) {SSCP};
        \node[rectangle,draw,rounded corners,fill=green!25,inner sep=8, right=0.6cm of a5] (b5) {\Large Imputation: 1\textsuperscript{st} row};
        \node[place,below=0.55cm of b4,] (c5) {Output};
        \node[place, below=0.5cm of b5] (a6) {Output};
        \node[trans, below=0.5cm of a6] (a7) {Copy imputed values for every row};
        \node[place, below=0.5cm of a7] (a8) {Output};
        \node[rectangle,draw,rounded corners,fill=green!25,inner sep=8, below=0.5cm of a8] (a9) {\Large Imputation: PXXXX\_O};
        \node[place, below=0.5cm of a9] (c10) {Output};
        \node[trans, left=0.5cm of c10] (b10) {Output N \\=\\ Input N+1};
        \node[place, left=0.5cm of b10] (a10) {Input};
        \node[trans, right=0.5cm of c10] (d10) {Save \\ iteration\\  output};
        \node[place, right=0.8cm of d10] (e10) {Output\_1};
        \node[below=1cm of c10 ,shape=rectangle,draw,rounded corners,fill=red!25,inner sep=4] (a11) {\LARGE \centering Imputation Step Iteration 2};
        \node[place,below=13cm of c1] (b12) {Working};
        \node[place,below=13cm of a1] (a12) {Input};    
        %  
        \draw [->,] (a1) -- (c1);
        \draw [->,] (a1) -- (a2);
        \draw [->,] (c1) -- (a2);
        \draw [->,] (a3) -- (a5);
        \draw [->,] (b3) -- (c5);
        \draw [->,] (a5) -- (b5);
        \draw [->,] (c5) -- (b5);
        \draw [->,] (b5) -- (a6);
        \draw [->,] (a6) -- (a8);
        \draw [->,] (a8) -- (a9);
        \draw [->,] (a9) -- (c10);  
        \draw [->,] (c10) -- (a10);
        \draw [->,] (c10) -- (e10);
        \draw [->,] (a10) |- (a11);
    \end{tikzpicture}
}
\end{document}

在此处输入图片描述

答案1

使用beamer文档类应该意味着您的图像在frame环境中...所以我将您的图像采用为标准大小frame。还使用库quotes进行边缘标记:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning, quotes}

\begin{document}
\begin{frame}[fragile]
\frametitle{Work flow?}
    \begin{center}
    \begin{tikzpicture}[,
node distance = 4mm and 6mm,
   box/.style = {rectangle, draw, rounded corners,
                 fill=#1, font=\footnotesize, inner ysep=1.5pt},
 box/.default = blue!25,
every edge/.style = {draw, semithick,-Stealth},
every edge quotes/.style = {auto=left, align=center, inner sep=2pt,
                            font=\scriptsize\linespread{0.7}\selectfont}
                        ]
\node (a1) [box]    {Input};
\node (a2) [box=red!25, font=\small,
            below right=of a1]      {Imputation Step Iteration 1};
\node (a3) [box,above right=of a2]  {Working};
\node (a4) [box,below  left=of a2]  {Input};
\node (a5) [box,below right=of a2]  {Working};
\node (a6) [box,below=of a4]    {SSCP};
\node (a7) [box,below=of a5]    {Output};
    \path (a6) -- node (a8) [box=green!25,inner sep=4pt]
                            {Imputation: 1\textsuperscript{st} row} (a7);
\node (a9)  [box,below=of a8]   {Output};
\node (a10) [box,below=of a9]   {Output};
\node (a11) [box=green!25,inner sep=4pt,
             below=of a10]    {Imputation: PXXXX\_O};
%
\node (a12) [box,below  left=of a11]    {Input};
\node (a13) [box,below=of a11]          {Output};
\node (a14) [box,below right=of a11]    {Output\_1};
\node (a15) [box=red!25,inner sep=4,
             below=of a13] {Imputation Step Iteration 2};
%
\node (a16) [box,below  left=of a15]   {Input};
\node (a17) [box,below right=of a15]   {Working};
        %
\draw   (a1) edge ["Replicate"] (a3)
        (a1) edge (a2)
        (a3) edge (a2)
%
        (a4) edge ["SSCPMISS"]  (a6)
        (a5) edge ["Replicate"] (a7)
        (a6) edge (a8)
        (a7) edge (a8)
%
        (a8) edge (a9)
        (a9) edge ["Copy imputed values for every row"] (a10)
        (a10) edge (a11)
        (a11) edge (a13)
%
        (a13) edge ["Output N =" ',"Input N+1"] (a12)%\\=\\ };
        (a13) edge ["Save iteration\\ output"] (a14)
%
        (a3) edge [bend left=44] (a17)
        ;
\draw[-Stealth] (a12) |- (a15);
\draw[-Stealth] (a14) |- (a15);
    \end{tikzpicture}
    \end{center}
\end{frame}
\end{document}

在此处输入图片描述

如果上面的图像仍然太大,您可以通过添加tikzpicture选项来缩小它,例如:scale=0.9, transform shape,

答案2

这是一个起点。我很乐意删除它。我会从中上部的大节点开始,然后绘制与此相关的内容。而且,正如 Joule V 所提到的,人们可以用来midway放置标签。(你正在添加auto但没有给 TiZ 有机会使用它。)

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\scalebox{0.6}[0.6]{
    \begin{tikzpicture}[>=stealth, place/.style={shape=rectangle,draw,rounded corners,fill=blue!25,},trans/.style={align=center},auto,scale=3]         
        \node[place,fill=green!25,inner sep=8, font=\Large ] (b5) {Imputation: 1\textsuperscript{st} row};
        \node[left=0.4cm of b5,place]  (a5) {SSCP};
        \node[right=0.4cm of b5,place]  (c5) {Output};
        \node[above=1cm of a5,place]  (a3) {Input};
        \node[above=1cm of c5,place]  (b3) {Working};
        \node[place,above=2cm of b5,fill=red!25,inner sep=4,font=\LARGE,align=center] 
        (a2) {Imputation Step Iteration 1};
        \node[place,above=2cm of a3] (a1) {Input};
        \node[place,above=2cm of b3] (c1) {Working};
        \draw [->] (a1) -- (c1) node[midway,above] (b1) {Replicate};
        \draw [->] (a3) -- (a5) node[midway,left,font=\footnotesize] (a4) {SSCPMISS};
        \draw [->] (b3) -- (c5) node[midway,right,font=\footnotesize]  (b4) {Replicate};
        \node[place, below=0.5cm of b5] (a6) {Output};
        \node[place, below=1.5cm of a6] (a8) {Output};
        \draw [->] (a6) -- (a8) node[midway,right,text width=3.5cm]{Copy imputed values for every row};
        \node[place,fill=green!25,inner sep=8, below=0.5cm of a8,font=\Large] (a9) {Imputation: PXXXX\_O};
        \node[place, below=0.5cm of a9] (c10) {Output};
        \node[place, left=3cm of c10] (a10) {Input};
        \draw [->] (c10) -- (a10) node[midway,auto=false,trans]
            (b10) {Output N \\=\\ Input N+1};
        \node[place, right=3cm of c10] (e10) {Output\_1};
        \draw [->] (c10) -- (e10) node[midway,trans,auto=false] (d10) {Save \\ iteration\\  output};
        \node[below=1cm of c10 ,place,fill=red!25,inner sep=4,font=\LARGE ] (a11) {Imputation Step Iteration 2};
        \node[place,below=13cm of c1] (b12) {Working};
        \node[place,below=13cm of a1] (a12) {Input};    
        %  
        \draw [->] (a1) -- (a2);
        \draw [->] (c1) -- (a2);
        \draw [->] (a5) -- (b5);
        \draw [->] (c5) -- (b5);
        \draw [->] (b5) -- (a6);
        \draw [->] (a8) -- (a9);
        \draw [->] (a9) -- (c10);  
        \draw [->] (a10) |- (a11);
        %
        \draw[->] (c1) to[out=-45,in=30] (b12);
    \end{tikzpicture}
}
\end{document}

在此处输入图片描述

相关内容