如何更改節點之間的方形箭頭連接 tikzpicture

如何更改節點之間的方形箭頭連接 tikzpicture

我正在使用 tikzpicture 繪製 Latex 中節點之間的連接。然而,連接並不好。我想知道如何才能獲得右側的預期結果。目前,我使用了以下程式碼,結果顯示在左側。先感謝您

在此輸入影像描述 這是我的程式碼

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption,subfig}
\usepackage{float}
\usepackage{xcolor}
\usepackage{tikz-qtree}
\usetikzlibrary{trees} % this is to allow the fork right path
\usepackage{tikz, xcolor}
\usetikzlibrary{shapes,arrows}
\usepackage[draft]{todonotes}   % notes showed

\begin{document}
\begin{figure} [H]
\centering
\begin{tikzpicture}[node distance = 3cm, auto]
    % Place nodes
    \node [label=above: A](A) {\includegraphics[width=0.15\textwidth]{example-image-a}}; 
    \node [label=below: B,below right=1cm and 1cm of A] (B) {\includegraphics[width=0.15\textwidth]{example-image-b}};
    \node [label=above: C ,above right=1cm and 1cm of A] (C) {\includegraphics[width=0.15\textwidth]{example-image-c}};
    \node [label=below: D,right = 1cm of B] (D) {\includegraphics[width=0.15\textwidth]{example-image-a}};
    \node [label=above: E,right = 1cm of C] (E) {\includegraphics[width=0.15\textwidth]{example-image-b}}; 
    \node [label=above: result1 ,right = 1cm of D] (result1){}; 
    \node [label=above: result2 ,right = 1cm of E] (result2){}; 
    \node [label=above: result3 ,above  of= result1] (result3){};
    % Draw arrow
    \draw[line width=0.3mm,->] (A) to (B);
    \draw[line width=0.3mm,->] (A) to (C);
    \draw[line width=0.3mm,->] (B) to (D);
    \draw[line width=0.3mm,->] (C) to (E);
    \draw[line width=0.3mm,->] (D) to (result1);
    \draw[line width=0.3mm,->] (E) to (result2);
    \draw[line width=0.3mm,->] (E) to (result3);
    \draw[line width=0.3mm,->] (D) to (result3);
\end{tikzpicture}
\captionsetup{labelfont={bf},font={color=blue}}
\caption{Test graph}
\label{fig:2n}
\end{figure}

\end{document}

答案1

您可以使用|--|結合使用--

\draw[line width=0.3mm,->] (A) -- ++(1.5cm,0) |- (B);
\draw[line width=0.3mm,->] (A) -- ++(1.5cm,0) |- (C);
\draw[line width=0.3mm,->] (E) -- ++(1.5cm,0) |- (result3);
\draw[line width=0.3mm,->] (D) -- ++(1.5cm,0) |- (result3);

相關內容