1

I produce a node/ edge plot with tikz using the following code:

\documentclass[tikz, border=5pt]{standalone}

\usepackage{tikz} 

\begin{document}
\begin{tikzpicture}[node distance=2cm]
    % nodes
    \node (A)  at (3.5, 5) {ABC};
    \node (B)   at (3.5, 4) {some slightly longer text in here};
    \node (C)  at (1, 3) {some other thext here};
    \node (D)  at (6, 3) {name of node displayed here};
    \node (E) at (9.5, 2) {name of another node about here};
    \node (F)  at (4, 2.5) {next node's titletext};
    \node (G) at (4, 1) {final node displayed here};

    % arrows
    \draw[->, to path={-| (\tikztotarget)}]
    (A) edge (B) (B) edge (C) (C) edge (F)
                              (C) edge (G)
                 (B) edge (D) (D) edge (E) (E) edge (G);        
\end{tikzpicture}
\end{document}

Unfortunately, the arrows aren't placed properly. I would like to roughly keep the configuration of the nodes and have some arrows start at the bottom of the node (e.g. bottom middle of node (A)) or go straight to the bottom (e.g. (from (C) to (G)) rather than first horizontally and then vertically. The picture below shows in black the output of above code; in red the lines I would roughly like to get (as arrows, of course), although I am not very set on these exact lines if it makes the code less complicated and more robust.

enter image description here

Thanks in advance for any suggestions for how to accomplish this and modify the edge starting points and paths.

2 Answers 2

1

enter image description here

Does this meet the requirement--the dash line can be replaced with arrows

The MWE

\documentclass[tikz, border=5pt]{standalone}

\usepackage{tikz} 

\begin{document}
\begin{tikzpicture}[node distance=2cm]
    % nodes
    \node (A)  at (3.5, 5) {ABC};
    \node (B)   at (3.5, 4) {some slightly longer text in here};
    \node (C)  at (1, 3) {some other thext here};
    \node (D)  at (6, 3) {name of node displayed here};
    \node (E) at (9.5, 2) {name of another node about here};
    \node (F)  at (4, 2.5) {next node's titletext};
    \node (G) at (4, 1) {final node displayed here};

    % arrows
    % \draw[->, to path={-| (\tikztotarget)}]
    % (A) edge (B) (B) edge (C) (C) edge (F)
    %                           (C) edge (G)
    %              (B) edge (D) (D) edge (E) (E) edge (G);  
    \draw [thick,dash dot, red] (A) -- (B);
    \draw [thick,dash dot, red] (B) -- (C);
    \draw [thick,dash dot, red] (C) -- (F);
    \draw [thick,dash dot, red] (C) -- (G);
    \draw [thick,dash dot, red] (B) -- (D);
    \draw [thick,dash dot, red] (D) -- (E);
    \draw [thick,dash dot, red] (E) -- (G);

\end{tikzpicture}
\end{document}

EDIT

for the arrows(red)

for the node (D) which is too close to node (C) \xshift added 4.5

enter image description here

MWE

\documentclass[tikz, border=5pt]{standalone}

\usepackage{tikz} 

\begin{document}
\begin{tikzpicture}[node distance=2cm]
    % nodes
    \node (A)  at (3.5, 5) {ABC};
    \node (B)   at (3.5, 4) {some slightly longer text in here};
    \node (C)  at (1, 3) {some other thext here};
    \node (D)  at (6, 3) {name of node displayed here};
    \node (E) at (9.5, 2) {name of another node about here};
    \node (F)  at (4.5, 2) {next node's titletext};
    \node (G) at (4, 1) {final node displayed here};

    % arrows
    % \draw[->, to path={-| (\tikztotarget)}]
    % (A) edge (B) (B) edge (C) (C) edge (F)
    %                           (C) edge (G)
    %              (B) edge (D) (D) edge (E) (E) edge (G);  
    \draw [->,thick,dash dot, red] (A) -- (B);
    \draw [->,thick,dash dot, red] (B) -- (C);
    \draw [->,thick,dash dot, red] (C) -- (F);
    \draw [->,thick,dash dot, red] (C) -- (G);
    \draw [->,thick,dash dot, red] (B) -- (D);
    \draw [->,thick,dash dot, red] (D) -- (E);
    \draw [->,thick,dash dot, red] (E) -- (G);

\end{tikzpicture}
\end{document}

EDIT

for Manhattan style mixed with regular style

node H defined new for a new arrow origin point

node D shifted right to create space for the arrow coming down from node H

MWE

\documentclass[tikz, border=5pt]{standalone}

\usepackage{tikz} 

\begin{document}
\begin{tikzpicture}[node distance=2cm]
    % nodes
    \node (A)  at (3.5, 5) {ABC};
    \node (B)   at (3.5, 4) {some slightly longer text in here};
    \node (C)  at (1, 3) {some other thext here};
    \node (D)  at (7, 3) {name of node displayed here};
    \node (E) at (9.5, 2) {name of another node about here};
    \node (F)  at (4.5, 2) {next node's titletext};
    \node (G) at (4, 1) {final node displayed here};
    \node (H) at (3.6,4) {};
    % \node (J) at (3.6,4) {};
    % arrows
    % \draw[->, to path={-| (\tikztotarget)}]
    % (A) edge (B) (B) edge (C) (C) edge (F)
    %                           (C) edge (G)
    %              (B) edge (D) (D) edge (E) (E) edge (G);  
    \draw [thick,dash dot, red] (A) -- (B);
    \draw  (B) |- (C);
    \draw [ red] (C) |- (F);
    \draw [->,thick,dash dot, red] (C) |- (G);
    \draw [->,thick, red] (H) |- (D);
    \draw [->,thick,dash dot, red] (D) -- (E);
    \draw [->,thick,dash dot, red] (E) -- (G);

\end{tikzpicture}
\end{document}

enter image description here

2
  • Thanks a lot - this is already much better than the original plot! :) Is there any way to not draw direct lines but lines in 'Manhattan distance' style? :)
    – Ivo
    Commented Jan 19, 2020 at 12:58
  • of course-- \draw (A) -| (B); will give you the desired result-- u can also experiment with |----- the - represents horizontal draw and | represents vertical line
    – js bibra
    Commented Jan 19, 2020 at 13:02
1

Here are some more alternatives:

enter image description here

\documentclass[tikz, border=5pt]{standalone}

\usepackage{tikz} 
\usetikzlibrary{positioning}

\begin{document}

    \begin{tikzpicture}[node distance=1cm]
        % nodes
        \node (A)  at (3.5, 5) {ABC};
        \node (B)[below of=A]{some slightly longer text in here};
        \node (C)[below left=  and -1cm of B]{some other thext here};
        \node (D)[below right= and -2cm of B]{name of node displayed here};
        \node (E)[below right= and -2cm of D] {name of another node about here};
        \node (F)[below =2cm of B]{next node's titletext};
        \node (G)[below=of F]{final node displayed here};

        % arrows
        \draw[->](A)--(B);
        \draw[->, to path={-| (\tikztotarget)}](B) edge (C)
                                               (B) edge (D)
                                               (D) edge (E);
        \draw[->, to path={|- (\tikztotarget)}](C) edge (F)
                                               (C) edge (G)
                                               (E) edge (G) ;        
    \end{tikzpicture}


\begin{tikzpicture}[node distance=1cm]
    % nodes
    \node (A)  at (3.5, 5) {ABC};
    \node (B)[below of=A]{some slightly longer text in here};
    \node (C)[below left=  and -1cm of B]{some other thext here};
    \node (C1)[right = -1.5cm of C]{\phantom{l}};
    \node (D)[below right= and -2cm of B]{name of node displayed here};
    \node (E)[below right= and -2cm of D] {name of another node about here};
    \node (F)[below =2cm of B]{next node's titletext};
    \node (G)[below=of F]{final node displayed here};

    % arrows
    \draw[->](A)--(B);
    \draw[->, to path={-| (\tikztotarget)}](B) edge (C)
                                           (B) edge (D)
                                           (D) edge (E);
    \draw[->, to path={|- (\tikztotarget)}](C1) edge (F)
                                           (C) edge (G)
                                           (E) edge (G) ;        
\end{tikzpicture}


\begin{tikzpicture}[node distance=1cm]
    % nodes
    \node (A)  at (3.5, 5) {ABC};
    \node (B)[below of=A]{some slightly longer text in here};
    \node (Cb)[below= of B.south west]{\phantom{l}};
    \node (C)[below left=  and -1cm of B]{some other thext here};
    \node (C1)[right = -1.5cm of C]{\phantom{l}};
    \node (Cd)[below= of B.south east]{\phantom{l}};
    \node (D)[below right= and -2cm of B]{name of node displayed here};
    \node (De)[below= of D.south east]{\phantom{l}};
    \node (E)[below right= and -2cm of D] {name of another node about here};
    \node (F)[below =2cm of B]{next node's titletext};
    \node (G)[below=of F]{final node displayed here};

    % arrows
    \draw[->](A)--(B);
    \draw[->](B.south west) -- (Cb);
    \draw[->](B.south east) -- (Cd);
    \draw[->](D.south east) -- (De);
    \draw[->, to path={|- (\tikztotarget)}](C1) edge (F)
                                           (C) edge (G)
                                           (E) edge (G) ;        
\end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .