改变 tikz 图形以拥有更多块

改变 tikz 图形以拥有更多块

我有下图:

数字

它是使用以下代码生成的:

\tikzset{%
block/.style    = {draw, thick, rectangle, minimum height = 3em,
    minimum width = 8em, fill=white, text width=2.5cm},
sum/.style      = {draw, circle, node distance = 2cm}, % Adder
input/.style    = {coordinate}, % Input
output/.style   = {coordinate}, % Output
virtual/.style = {coordinate}
}
\begin{tikzpicture}[auto, thick, node distance=2cm, >=triangle 45]
\draw
node at (0,0){}
node [input, name=input1] {} 
node [output, name=output1, right = 1cm of input1] {};
\node [align=center, block, right = 0.5cm of output1] (model) {glamor};
\node [align=center, block, right = 1.5cm of model] (model1) {trainer};
\node [virtual, left=of model.165] (input)     {};
\node [virtual, right=of model1.0] (output)    {};
\node [virtual, below left=of model.west] (feedback)  {};
\draw[->](input1) -- node {$mm$}(model);
\draw[->](model) -- node {$mnn$} (model1);
\draw [->] (model1) -- node [name=y] {$ppx$}(output);
\draw [->,rounded corners] (model1) -- (y.south) |- (feedback) |- (model.195);
\end{tikzpicture}

我想在这个图中添加 2 个块以及底部箭头中的额外箭头,看起来如下所示: 更改了图

答案1

我不明白为什么需要所有virtualinputoutput节点,因此我删除了这些节点,并以我认为更有意义的方式重命名了剩余节点。使用相对放置,您可以实现:

在此处输入图片描述

使用代码:

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

\begin{document}

\tikzset{%
  block/.style = { draw,
                   thick,
                   rectangle,
                   minimum height = 3em,
                   fill=white,
                   align=center
   },
   wide block/.style = {
                   block,
                   text width=2.5cm,
                   minimum width = 8em,
   }
}

  \begin{tikzpicture}[auto, thick, node distance=2cm, >=Triangle]
    \node[wide block] (glamor) {glamor};
    \node[wide block, right = 15mm of glamor] (trainer) {trainer};
    \node[block, below=10mm of glamor.south east](M){M};
    \node[block, below=10mm of trainer.south west](L){L};
    \draw[<-](glamor.west) --node[above]{$mm$} ++(-2,0);
    \draw[->](glamor) -- node {$mnn$} (trainer);
    \draw[->](trainer.east) -- node[name=y]{$ppx$} ++ (2,0);
    \draw[->,rounded corners](trainer.east) -- ++(1,0) |- (L);
    \draw[->](L)--(M);
    \draw[<-, rounded corners]([yshift=1mm]glamor.south west) 
           -- ++(-1,0) |- (M.west);
  \end{tikzpicture}

\end{document}

我不会按照 OP 所建议的方式这样做,而是会使用:

    \node[block, below=10mm of glamor](M){M};
    \node[block, below=10mm of trainer](L){L};

从而得到更加对称的:

在此处输入图片描述

相关内容