我正在尝试通过添加多个点状背景来制作以下流程图。我知道使用 Tikz 创建简单流程图的基础知识,但是,我想知道如何创建如下所示的稍微复杂的流程图。我在 MS PowerPoint 中创建了该图。
我创建的简单流程图的 MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{adjustbox}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{automata,positioning}
\usetikzlibrary{shapes.multipart}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, text width=3cm,draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
node distance=2cm
]
\node (pro1) [process, below of=in1,yshift=-0.5cm] {Meshing\\A};
\node (pro0) [process, left of=pro1, xshift=-2.5cm] {Design\\A};
\node (pro2) [process, below of=pro1,yshift=-0.5cm] {solver setup};
\node (pro) [process, right of=pro2, xshift=2.5cm] {A\\+\\B};
\node (dec1) [decision, below of=pro2, yshift=-0.8cm] {i = N?};
\node (dec2) [decision, left of=dec1, xshift=-2.5cm] {Converged?};
\node (pro5) [process, left of=dec2, xshift=-2.5cm] {i = i+1};
\node (pro6) [process, below of=dec1, yshift=-1cm] {Post processing};
\draw [arrow] (pro0) -- (pro1);
\draw [arrow] (pro1) -- (pro2);
\draw [arrow] (pro) -- (pro2);
\draw [arrow] (pro2) -- (dec1);
\draw [arrow] (dec1) -- node[anchor=south] {No} (dec2);
\draw [arrow] (dec2) -- node[anchor=south] {No} (pro5);
\draw [arrow] (pro5) |- (pro2);
\draw [arrow] (dec1) -- node[anchor=west] {Yes} (pro6);
\draw [arrow] (dec2) |- node[anchor=north] {Yes} (pro6);
\end{tikzpicture}
\end{figure}
\end{document}
这提供了一个简单的输出:
但是,我正在寻找更复杂的输出,如下所示:
提前感谢您的时间和帮助。
答案1
fit
这里有一些非常通用的东西,只是为了展示在这种特殊情况下该库的用法。
请注意,我重新替换了你的所有tikzstyle
内容tikzset
,它们是现代的Ti 中的设计样式的方法钾Z。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{adjustbox}
\usetikzlibrary{shapes.geometric, arrows, fit}
\usetikzlibrary{automata,positioning}
\usetikzlibrary{shapes.multipart}
\tikzset{
startstop/.style =
{rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30},
io/.style =
{trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, text width=3cm,draw=black, fill=blue!30},
process/.style = {rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30},
decision/.style = {diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style = {thick,->,>=stealth},
myfit/.style={draw,dashed,blue, inner xsep=10pt, inner ysep=15pt, rounded corners=5pt},
mytitle/.style={draw,densely dashed,blue, fill=orange!50, inner sep=5pt, right, xshift=10pt}
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
node distance=2cm
]
\node (pro1) [process, yshift=-0.5cm] {Meshing\\A};
\node (pro0) [process, left of=pro1, xshift=-2.5cm] {Design\\A};
\node (pro2) [process, below of=pro1,yshift=-0.5cm] {solver setup};
\node (pro) [process, right of=pro2, xshift=2.5cm] {A\\+\\B};
\node (dec1) [decision, below of=pro2, yshift=-0.8cm] {i = N?};
\node (dec2) [decision, left of=dec1, xshift=-2.5cm] {Converged?};
\node (pro5) [process, left of=dec2, xshift=-2.5cm] {i = i+1};
\node (pro6) [process, below of=dec1, yshift=-1cm] {Post processing};
\draw [arrow] (pro0) -- (pro1);
\draw [arrow] (pro1) -- (pro2);
\draw [arrow] (pro) -- (pro2);
\draw [arrow] (pro2) -- (dec1);
\draw [arrow] (dec1) -- node[anchor=south] {No} (dec2);
\draw [arrow] (dec2) -- node[anchor=south] {No} (pro5);
\draw [arrow] (pro5) |- (pro2);
\draw [arrow] (dec1) -- node[anchor=west] {Yes} (pro6);
\draw [arrow] (dec2) |- node[anchor=north] {Yes} (pro6);
\node[fit=(pro1)(pro0),myfit] (myfit1) {};
\node[mytitle] at (myfit1.north west) {Pre-processing};
\draw[arrow,blue] (myfit1) -| (pro);
\end{tikzpicture}
\end{figure}
\end{document}