如何用 Tikz 绘制从一个块到两个块的箭头

如何用 Tikz 绘制从一个块到两个块的箭头

我想画一个像下面这样的图,但我不知道如何画一个从一个块到两个块的箭头,就像到源 1/源 2 的箭头,以及如何画一个从两个块到一个块的箭头,就像从源 1/源 2 的箭头。有人能帮帮我吗! 在此处输入图片描述

这是我能做到的:

\tikzstyle{rect} = [draw, rectangle, minimum height = 4em, text width = 6em, text centered]
\tikzstyle{line} = [draw, -latex']

\begin{figure}
    \begin{center}
        \begin{tikzpicture}[node distance = 3cm, auto]
        \node[rect](signal) {Signal};
        \node[rect, right of=signal](STFT) {STFT};
        \node[rect, right of=STFT](sep) {DNN/RNN};
        \node[rect, right of=sep](speech) {$Source_1$};
        \node[rect, below of=speech](music) {$Source_2$};
        \node[rect, below of=sep](mask) {Time Frequencey Masking};
        \node[rect, left of=mask](ISTFT) {ISTFT};
        \node[rect, left of=ISTFT](eval) {Evaluation};

        \path[line] (signal) -- (STFT);
        \path[line] (STFT) -- (sep);
        \path[line] (sep) -- (speech);
        \path[line] (sep) -- (music);
        \path[line] (mask) -- (ISTFT);
        \path[line] (ISTFT) -- (eval);
        \end{tikzpicture}
    \end{center}
\end{figure}

答案1

像这样:

在此处输入图片描述

代码:

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows, chains, fit, positioning, scopes}

\begin{document}
    \begin{tikzpicture}[
            > = angle 90,
node distance = 6mm and 8mm,
   box/.style = {draw, minimum height=10mm, minimum width=27mm,
                 align=center, join=by ->, on chain}, 
         font = \sffamily
                    ] 
{ [start chain = A going right]
\node[on chain] {Signal};
\node[box]      {STFT/log-mel};
\node[box]      {DNN/RNN};
}
{ [start chain = B going left]
\node[box,below=of A-3]      
                {Time Frequency\\ Masking};
\node[box]      {ISTFT};
\node[box]      {Evaluation};             
} 
\node (s1)  [right=of A-3.north east] {Source\textsubscript{1}};
\node (s2)  [right=of A-3.south east] {Source\textsubscript{2}};
% 
\node[draw, dotted, inner sep = 5mm, xshift=1mm, fit=(A-3) (B-1) (s1)] {};
\draw (A-3.east) -- ++ (4mm,0) coordinate (s0);
\draw[->] (s0)  |- (s1);
\draw[->] (s0)  |- (s2);
\draw[->] (A-3 -| s1.east) -- + (4mm,0) |- (B-1);  
    \end{tikzpicture}
\end{document}

节点位置由库chains和确定scope。形成两个链:A 和 B。链中节点之间的箭头由join=by ->框样式选项绘制。将链 A 与节点“Source_1”和“Source_2”连接的箭头分别绘制。语法|-用于绘制垂直线。

编辑:我注意到一个拼写错误,现在已更正。我还利用此更正对图纸进行了轻微更改(现在所有节点的大小都相同)。

相关内容