3

I made the following diagram in Tikz. MWE is given below and it needs some refinement for nodes where they split into two arrows. Any help will be highly appreciated. Thanks

enter image description here

\documentclass{standalone}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,arrows}

\begin{document}


% Define block styles

\tikzstyle{block} = 
    [
        rectangle
      %, draw
     % , fill=blue!20
      , text width=5.0em
      , text centered
      , node distance=2.5cm
      , rounded corners
      , minimum height=1em
      ]

\tikzstyle{line} = 
    [
        draw
     , -latex'
     ]



\begin{tikzpicture}[node distance = 2cm, auto]


  % Place nodes
    \node [block] (Econo) {Econometrics};
    \node [block, below left of=Econo, node distance=2cm, xshift=-1.0cm] (Theoretical) {Theoretical};
    \node [block, below right of=Econo, node distance=2cm, xshift=1.0cm] (Applied) {Applied};

  % Draw edges
    \path[line] let \p1=(Econo.south), \p2=(Theoretical.north) in (Econo.south) -- +(0,0.5*\y2-0.5*\y1) -| (Theoretical.north);
    \path[line] let \p1=(Econo.south), \p2=(Applied.north) in (Econo.south) -- +(0,0.5*\y2-0.5*\y1) -| (Applied.north);

  % Place nodes     
    \node [block, below left of=Theoretical, node distance=2.5cm, xshift=0.75cm] (TheoreticalClassical) {Classical};
    \node [block, below right of=Theoretical, node distance=2.5cm, xshift=-0.75cm] (TheoreticalBayesian) {Bayesian};

  % Draw edges
    \path[line] let \p1=(Theoretical.south), \p2=(TheoreticalClassical.north) in (Theoretical.south) -- +(0,0.5*\y2-0.5*\y1) -| (TheoreticalClassical.north);
    \path[line] let \p1=(Theoretical.south), \p2=(TheoreticalBayesian.north) in (Theoretical.south) -- +(0,0.5*\y2-0.5*\y1) -| (TheoreticalBayesian.north);


  % Place nodes     
    \node [block, below left of=Applied, node distance=2.5cm, xshift=0.75cm] (AppliedClassical) {Classical};
    \node [block, below right of=Applied, node distance=2.5cm, xshift=-0.75cm] (AppliedBayesian) {Bayesian};

  % Draw edges
    \path[line] let \p1=(Applied.south), \p2=(AppliedClassical.north) in (Applied.south) -- +(0,0.5*\y2-0.5*\y1) -| (AppliedClassical.north);
    \path[line] let \p1=(Applied.south), \p2=(AppliedBayesian.north) in (Applied.south) -- +(0,0.5*\y2-0.5*\y1) -| (AppliedBayesian.north);

\end{tikzpicture}

\end{document}
MYaseen208
  • 8,587
  • @MYassen208, your image actually shows tree diagram. Is there special reason, that you didn't use TikZ trees library for drawing it? See my (late) answer. – Zarko Sep 28 '15 at 13:51
  • Would you suggest to use trees library for path diagrams here and here @Zarko? Thanks – MYaseen208 Sep 29 '15 at 13:00
  • Image in given ling doesn't contain tree structure. It more remain on an automaton. And there you have two excellent answers how draw such images. No, for such image library trees is not very useful. Read tutorials in the firs chapter of TikZ manual as well third chapter "TikZ ist kein Zeichenprogramm". There is lot of examples of TikZ use. Helpful is also http://www.texample.net/. There area lot (more than hundred) examples. – Zarko Sep 29 '15 at 13:19
  • if you still have concrete problem with similar diagrams, as you just ask in given question, just ask again :-). – Zarko Sep 29 '15 at 13:30

3 Answers3

5

I've rewritten the whole code to make it more manageable and readable. I've added the names of nodes in the diagram so that you can easily access the nodes in the code. Now you can easily change node distance=1cm if you want to increase or decrease the distance between nodes.

\documentclass[border={10pt}]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows}

\begin{document}
\begin{tikzpicture}
    [%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       node distance=1cm,
       arrow/.style={->, >=stealth, very thick},
       block/.style={rectangle, fill=blue!20, text centered, 
                     rounded corners, minimum height=1em}                      
    ]%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %create nodes
    \node[block] (A)                                               {Classical (A)};
    \node[block] (B) [right=of A]                                  {Bayesian (B)};
    \node[block] (C) [above=of B] at (barycentric cs:A=0.1,B=0.1)  {Theoretical (C)};
    \node[block] (D) [right=of B]                                  {Classical (D)};
    \node[block] (E) [right=of D]                                  {Bayesian (E)};
    \node[block] (F) [above=of E] at (barycentric cs:D=0.1,E=0.1)  {Applied (F)};
    \node[block] (G) [above=of C] at (barycentric cs:C=0.1,F=0.1)  {Econometrics (G)};

    %connect nodes
    \draw [arrow] (G.south) -- ++(0,-.3) -| (C.north);
    \draw [arrow] (G.south) -- ++(0,-.3) -| (F.north);
    \draw [arrow] (C.south) -- ++(0,-.3) -| (A.north);
    \draw [arrow] (C.south) -- ++(0,-.3) -| (B.north);
    \draw [arrow] (F.south) -- ++(0,-.3) -| (D.north);
    \draw [arrow] (F.south) -- ++(0,-.3) -| (E.north);
\end{tikzpicture}
\end{document}

enter image description here

CroCo
  • 5,902
2

Load positioning library and change all of = to = of in the node specifications. Your problems will be solved. Always use this library for positioning as this is more accurate. Also, it is better to use tikzset instead of obsolete tikzstyle as I did.

\documentclass{standalone}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,arrows,positioning}

\begin{document}


% Define block styles

\tikzset{block/.style =
    {
        rectangle
      %, draw
     % , fill=blue!20
      , text width=5.0em
      , text centered
      , node distance=2.5cm
      , rounded corners
      , minimum height=1em
      },
line/.style =
    {
        draw
     , -latex'
     }
}



\begin{tikzpicture}[node distance = 2cm, auto]


  % Place nodes
    \node [block] (Econo) {Econometrics};
    \node [block, below left = of Econo, node distance=2cm, xshift=-1.0cm] (Theoretical) {Theoretical};
    \node [block, below right = of Econo, node distance=2cm, xshift=1.0cm] (Applied) {Applied};

  % Draw edges
    \path[line] let \p1=(Econo.south), \p2=(Theoretical.north) in (Econo.south) -- +(0,0.5*\y2-0.5*\y1) -| (Theoretical.north);
    \path[line] let \p1=(Econo.south), \p2=(Applied.north) in (Econo.south) -- +(0,0.5*\y2-0.5*\y1) -| (Applied.north);

  % Place nodes
    \node [block, below left = of Theoretical, node distance=2.5cm, xshift=0.75cm] (TheoreticalClassical) {Classical};
    \node [block, below right = of Theoretical, node distance=2.5cm, xshift=-0.75cm] (TheoreticalBayesian) {Bayesian};

  % Draw edges
    \path[line] let \p1=(Theoretical.south), \p2=(TheoreticalClassical.north) in (Theoretical.south) -- +(0,0.5*\y2-0.5*\y1) -| (TheoreticalClassical.north);
    \path[line] let \p1=(Theoretical.south), \p2=(TheoreticalBayesian.north) in (Theoretical.south) -- +(0,0.5*\y2-0.5*\y1) -| (TheoreticalBayesian.north);


  % Place nodes
    \node [block, below left = of Applied, node distance=2.5cm, xshift=0.75cm] (AppliedClassical) {Classical};
    \node [block, below right = of Applied, node distance=2.5cm, xshift=-0.75cm] (AppliedBayesian) {Bayesian};

  % Draw edges
    \path[line] let \p1=(Applied.south), \p2=(AppliedClassical.north) in (Applied.south) -- +(0,0.5*\y2-0.5*\y1) -| (AppliedClassical.north);
    \path[line] let \p1=(Applied.south), \p2=(AppliedBayesian.north) in (Applied.south) -- +(0,0.5*\y2-0.5*\y1) -| (AppliedBayesian.north);

\end{tikzpicture}

\end{document}

enter image description here

2

Your image can be simply drawn with help of trees TikZ library:

\documentclass[border=3mm,
               tikz,
               preview]{standalone}
\usetikzlibrary{arrows,shapes,trees}
    \usepackage[latin1]{inputenc}

\begin{document}
    \begin{tikzpicture}[
every node/.style = {shape=rectangle, rounded corners, draw=blue!50,
                     inner sep=1mm, outer sep=0mm, minimum height=5mm,
                     top color=blue!10, bottom color=blue!30,
                     align=center, anchor=north},
         level distance = 11mm,
         level 1/.style = {sibling distance=42mm},
         level 2/.style = {sibling distance=24mm},
edge from parent fork down,
edge from parent/.style = {draw, semithick, -latex},
                        ]
\node   {Econometrics}
    child {node {Theoretical}
        child {node {Classical}}
        child {node {Bayesian}}
            }
    child {node {Theoretical}
        child {node {Classical}}
        child {node {Bayesian}}
            };
    \end{tikzpicture}
\end{document}

Obtained image (if you don't liked node design, just adequate change every node style) is:

enter image description here

Nodes position is determined by level and sibling distance.

Edit: For adding of comments on the left side of image, you need to give names to nodes (at least on the left side of tree). They are used for properly aligning of nodes. In the case, that the comment has different layout as nodes in tree, for them is good think to define separate style for them.

Considering aforementioned, the MWE is now:

    \documentclass[border=3mm,
                   tikz,
                   preview]{standalone}
    \usetikzlibrary{arrows,positioning,shapes,trees}
        \usepackage[latin1]{inputenc}

    \begin{document}
        \begin{tikzpicture}[
        node distance=0mm,
    every node/.style = {shape=rectangle, rounded corners, draw=blue!50,
                   inner sep=1mm, outer sep=0mm, minimum height=5mm,
                   %
                   align=center, anchor=north},
    cmnt/.style = {shape=rectangle, draw=none,
                   inner sep=0mm, outer sep=0mm, minimum height=5mm,
                   align=right},
             level 1/.style = {sibling distance=42mm},
             level 2/.style = {sibling distance=24mm},
    edge from parent fork down,
    edge from parent/.style = {draw, semithick, -latex},
                            ]
\begin{scope}[every node/.append style={top color=blue!10, bottom color=blue!30}]
    \node   (L1)   {Econometrics}% L should associate on "Level"
        child {node (L2) {Theoretical}
            child {node (L3)  {Classical}}
            child {node {Bayesian}}
                }
        child {node {Theoretical}
            child {node {Classical}}
            child {node {Bayesian}}
                };
\end{scope}
%from bottom to top
\node[cmnt] (l3)    [left=3mm of L3,% select according your needs
                    ] {comment for\\ the third level};
\node[cmnt] (l2)    [left=of l3.east |- L2.west,% right aligned with level 3 comment
                    ] {comment for\\ the second level};
\node[cmnt] (l1)    [left=of l3.east |- L1,% right aligned with level 3 comment
                    ] {one line comment};
        \end{tikzpicture}
    \end{document}

It gives the following result:

enter image description here

Zarko
  • 296,517
  • I like this one. Thanks a lot. Much appreciated. – MYaseen208 Sep 28 '15 at 15:33
  • Would highly appreciate if you guide me how to get text comments to the leftmost of each level. Thanks – MYaseen208 Sep 28 '15 at 16:53
  • @MYaseen208, for this you need to give names to (at least left sides) node, and than ad the nodes with desired text. I will upgrade my answer with this. – Zarko Sep 28 '15 at 17:07
  • @MYaseen208, I'm not very fast in typing :-(, so I need more time for reconstruction of given answer according to your request ... – Zarko Sep 28 '15 at 17:44
  • @MYaseen208, I'm glad to help you. However, with accepting the answer you show, which solution is appropriate for you. Apparently it is not mine :-), so why you have such interest for my answer? I wish you happy TeXing! – Zarko Sep 29 '15 at 13:26