如何制作此流程图

如何制作此流程图

我想要这个图表。非常感谢您的帮助。:

所以我现在看到这个代码,我仍然卡在箭头之间的文字和带有正确和错误表情符号的虚线框中

到目前为止我有这个代码:

 \documentclass{article}
    \usepackage{fourier}
    \usepackage[table,xcdraw,dvipsnames,svgnames,x11names]{xcolor}
    \usepackage{tikz}
    \usetikzlibrary{shapes,shadows,arrows.meta,
    backgrounds,
    fit,
    matrix,
    positioning,
    quotes}
    
    \tikzset{mytext/.style={font=\fontfamily{put}\selectfont\tiny,align=center,color=black}
        ,
    rec/.style={mytext,rectangle,minimum height=1cm,minimum width=1.5cm,fill=Green,draw=red!150},}
    
    
    
    
    \begin{document}
    
    \begin{tikzpicture}
    \node [rec] (a) {Initial broad high \\throughput \\screening};
    \coordinate [right = 2cm of a](b){};
    \coordinate [below = 2cm of b](c){};
    \node[rec,right=2cm  of c](d){Mixed variable\\ Multi-Objective\\ optimization};
    \coordinate [right = 2cm of d](e){};
    \coordinate [above = 2cm of e](f){};
    \node[rec,right=2cm of f](g){Scale-Up};
    \coordinate[above=2cm of f](k){};
    \node[rec,left=0.5cm of k](l){Further Continuous \\parameter optimization\\ for selected discrete \\ variable};
    \node[rec,left=1.2cm of l](m){xd};
    \draw[arrow,black] (a. east) -> (b. west);
    \draw[arrow,black] (b.east ) |- (d. west);
    \draw[arrow,black] (d.west) |- (e.mid east );
    \draw[arrow,black] (e. right) |- (f. left);
    \draw[arrow,black] (f. right) |- (g. left);
    \draw[arrow,black] (f. right) |- (k. left);
    \draw[arrow,black] (k. right) |- (l. right);
    \draw[arrow,black] (l. right) |- (m. right);
    \draw[arrow,black] (b. right) |- (m. left);
    
    
    \end{tikzpicture}
    \end{document}

答案1

这是一种使用绝对坐标来实现的方法,在我看来,这至少在开始时可以提供更多的控制。

从图形设计的角度来看,我不会将您的框图与注释混淆:它们更适合简洁的比较,而用于此的工具是...表格。而就目前的情况而言,可读性肯定是一个问题。

因此,让我们集中注意力于该图表并观察一些特殊之处。

开始

暂时忘掉样式:您将根据需要随时引入它们。从放置 5 个节点(您的块)开始。

    % ~~~ place your functional blocks ~~~~~~~~~~~~~~~~~~~~~~~~~~
    \node[block] (A) at ( -4, 0) {Initial broad high \\throughput \\screening};
    \node[block] (M) at ( 4, 2){xd};
    \node[block] (L) at (10, 2){Further Continuous \\parameter optimization\\                                                   for selected discrete \\ variable};
    \node[block] (D) at ( 8,-2) {Mixed variable\\ Multi-Objective\\ optimization};  
    \node[block] (G) at (18, 0) {Scale-Up}; 

他们的坐标可能是初步的,您可以随时调整它们(=经常编译)。确保它或多或少是您想要的。

正在连接

第一种方法应该是直接将这些节点交叉连接起来。首先不要关心对齐等。

在这样做的同时,在输入之后和输出之前放置 2 个额外点以简化箭头类型和颜色非常有用:

    % ~~~ some coordinates ~~~~~~~~~~~~
    \coordinate (P1) at (2,0);
    \coordinate (P2) at (12,0);

改善连接

基本上你首先要介绍以下内容:

    % upper branch
    \draw[arr1] (P1) |- (M);
    \draw[arr1] (M)  -- (L);
...

现在可能发现放置一些文本节点很有用。一旦你理解了 Tikz 的路径思想,就更容易了:

  • 路径以...开头\
  • 以。。结束;
  • 中间的一切都是“动作”(就像电影里一样)
  • 通常你只需要draw,但你也可以把node// 在这里观察缺失的内容\
    \draw[arr1] (M)  -- node[txt]{Finalise\\discrete\\variable\\selection}
                        (L);

默认情况下,它只是放在midway (或在pos=0.5)两点之间,这里是(M)和(L)。这只是上部反馈回路的一个变体,使用相对坐标中的一些中间点:

    \draw[arr1,dashed] (M.east) -- ++(0.5,0) -- ++(0,2)
                   -| node[txt,pos=.1]{Further\\reduction} (M.north); 

相同的想法,在路径结束之前和 Tikz 尝试渲染它之前需要进行更多操作;通过使用pos=.1或,您可以沿着路径移动文本,即在其(较短的)起点和终点之间。

样式 / 格式

它们会随着你的进步而发展。除了将它们移动到 tikzpicture 并使用你的定义之外,你还会看到,我如何尝试使用分层(=重新使用先前的定义)方法来处理箭头和线条。

 \begin{tikzpicture}[% ~~~ move styles here ~~~~~~~~~~~~~
    >={Stealth},    % replacing all arrow tips
    mytext/.style ={font=\fontfamily{put}\selectfont\tiny,
                    align=center,color=black},
    block/.style  ={mytext,rectangle,minimum height=1cm,minimum width=1.5cm,
                    fill=green,draw=red!150},
    % ~~~ for all those lines (used hierarchically) ~~~~~~~~~
    lnw/.style={line width=2pt},
    arr/.style={->,lnw},
    arr1/.style={arr,draw=green!50!blue!100},
    arr2/.style={lnw,draw=green!50!blue!100},
    arr3/.style={arr,draw=teal!70!black!60},
    arr4/.style={lnw,draw=teal!70!black!60},
    % ~~~ for the text nodes ~~~~~~~~~~~
    txt/.style={fill=gray!10,align=center},% or just fill white
 ]

最后的建议

为了学习目的,我建议执行以下操作:

  • 将以下代码复制到新文件中
  • 删除节点后的所有内容(或将其注释掉)
  • 编译
  • 重复并删除较少的代码,即“遍历”连接器等。

这样,您就能更清楚地了解发生了什么,并更好地掌握每行代码的含义。

结果

\documentclass[10pt,border=3mm]{standalone} % more useful during development

\usepackage{tikz}
\usetikzlibrary{arrows.meta}

    
\begin{document}  
 \begin{tikzpicture}[% ~~~ move styles here ~~~~~~~~~~~~~
    >={Stealth},    % replacing all arrow tips
    mytext/.style ={font=\fontfamily{put}\selectfont\tiny,
                    align=center,color=black},
    block/.style  ={mytext,rectangle,minimum height=1cm,minimum width=1.5cm,
                    fill=green,draw=red!150},
    % ~~~ for all those lines (used hierarchically) ~~~~~~~~~
    lnw/.style={line width=2pt},
    arr/.style={->,lnw},
    arr1/.style={arr,draw=green!50!blue!100},
    arr2/.style={lnw,draw=green!50!blue!100},
    arr3/.style={arr,draw=teal!70!black!60},
    arr4/.style={lnw,draw=teal!70!black!60},
    % ~~~ for the text nodes ~~~~~~~~~~~
    txt/.style={fill=gray!10,align=center},
 ]
    % ~~~ place your functional blocks ~~~~~~~~~~~~~~~~~~~~~~~~~~
    \node[block] (A) at ( -4, 0) {Initial broad high \\throughput \\screening};
    \node[block] (M) at ( 4, 2){xd};
    \node[block] (L) at (10, 2){Further Continuous \\parameter optimization\\                                                   for selected discrete \\ variable};
    \node[block] (D) at ( 8,-2) {Mixed variable\\ Multi-Objective\\ optimization};  
    \node[block] (G) at (18, 0) {Scale-Up}; 
    
    % ~~~ some coordinates ~~~~~~~~~~~~
    \coordinate (P1) at (2,0);
    \coordinate (P2) at (12,0);
    
    % ~~~ connector paths with text-nodes ~~~~~~~~~~~~~~~~~~~~~
    % input
    \draw[lnw]  (A)  -- node[txt]{Select best performing\\discrete variables}
                        (P1);
    
    % upper branch
    \draw[arr1] (P1) |- (M);
    \draw[arr1] (M)  -- node[txt]{Finalise\\discrete\\variable\\selection}
                        (L);
    \draw[arr2] (L)  -| (P2);
    
    \draw[arr1,dashed] (M.east) -- ++(0.5,0) -- ++(0,2)
                   -| node[txt,pos=.1]{Further\\reduction} (M.north); 
    
    % output
    \draw[arr]  (P2) -- node[txt]{Optimum continuous\\and\\discrete conditions}
                        (G);
    
    % lower branch
    \draw[arr3] (P1) |- (D);
    \draw[arr4] (D)  -| (P2);
 
 \end{tikzpicture}
\end{document}

答案2

还没有解决方案,只是进行了一些调试以给您一些反馈:

  • 看起来你很困惑\node\coordinate
  • \nodes 具有形状,因此具有尺寸,因此eastwest是不同的点(或坐标)
  • \coordinates 的维度为零,因此east等没有意义
%\documentclass{article}
\documentclass[10pt,border=3mm]{standalone} % more useful during development

% ~~~ commented out all packages not needed here ~~~~~~~~
%    \usepackage{fourier}
%    \usepackage[table,xcdraw,dvipsnames,svgnames,x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{
%shapes,shadows,
arrows.meta,
%    backgrounds,
%    fit,
%    matrix,
    positioning,
%    quotes
}
%    
\tikzset{
    mytext/.style={font=\fontfamily{put}\selectfont\tiny,align=center,color=black},
    rec/.style={mytext,rectangle,minimum height=1cm,minimum width=1.5cm,fill=green,draw=red!150},% <<< green
    arrow/.style={-{Stealth}},
}
    
    
\begin{document}  
 \begin{tikzpicture}
    \node       [rec]               (a) {Initial broad high \\throughput \\screening};
    \coordinate [right = 2cm of a]  (b);    %{}; !!! it's a coordinate, not a node
    \coordinate [below = 2cm of b]  (c);    %{};
    
    \node       [rec,right=2cm  of c](d){Mixed variable\\ Multi-Objective\\ optimization};
    \coordinate [right = 2cm of d]  (e);    %{};
    \coordinate [above = 2cm of e]  (f);    %{};
    
    \node       [rec,right=2cm of f](g){Scale-Up};
    \coordinate [above=2cm of f]    (k);    %{};
    
    \node       [rec,left=0.5cm of k](l){Further Continuous \\parameter optimization\\ 
                                         for selected discrete \\ variable};
    \node       [rec,left=1.2cm of l](m){xd};
    \draw[arrow,black] (a) -- (b);
%   \draw[arrow,black] (b.east ) |- (d.west);
%    \draw[arrow,black] (d.west) |- (e.mid east );
%    \draw[arrow,black] (e. right) |- (f. left);
%    \draw[arrow,black] (f. right) |- (g. left);
%    \draw[arrow,black] (f. right) |- (k. left);
%    \draw[arrow,black] (k. right) |- (l. right);
%    \draw[arrow,black] (l. right) |- (m. right);
%    \draw[arrow,black] (b. right) |- (m. left);
 
 \end{tikzpicture}
\end{document}

中间的

相关内容