1

How is it possible to draw this figure?

enter image description here

There are some posts on how to draw a tree of an extensive game model, but I don't know how to modify them such that the following figure is produced.

Nth Problem with TikZ and Extensive Form Games Game theory trees, solid node size

1
  • Please search about the tree llibrary. You may find help to begin with. Then edit your post with your MWE and your questions. Sure you will find someone to help you improve it. But asking for such a complex graph from scratch doesn't guarantee any answer here ;) – SebGlav Feb 17 at 18:37
5

Here is my attempt:

\documentclass[border=0.2cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
    
\begin{document}
     
\begin{tikzpicture}[thick, node distance=3cm,on grid,
    Rec/.style = {
        draw, 
        minimum size = 1cm,
        outer sep=0},
    Circ/.style= {
        draw,
        circle,
        minimum size=1cm}]
 % Rectangles and circle
 \node[Rec,fill=gray] (rec1) {}; 
 \node[Rec,right=of rec1] (rec2) {};
 \node[Circ,right=of rec2] (circle) {};
 \node[Rec,above right=2cm and 3cm of circle] (rec3) {};
 \node[Rec,below right=2cm and 3cm of circle] (rec4) {};

    
% Directed lines
    \draw[-latex] (rec1) -- (rec2) edge node[above left](Nbuy){Buy}(circle);
    \draw[-latex] (circle) |- (rec3) node[pos=0.71,above]{Match}node[pos=0.71,below]{$m$}   (circle) |- (rec4) node[pos=0.71,below]{Mismatch}node[pos=0.71,above]{$1-m$} ; 
      
    \draw (rec3) |- ++(2,1) node[pos=0.71,above]{Keep} node[right]{$v-P$} (rec3) |- ++(2,-1)node[pos=0.75,below]{Return}  node[right]{$v-h$};

\draw (rec4) |- ++(2,1) node[pos=0.71,above]{Keep}  node[right]{$s-P$}(rec4) |- ++(2,-1)node[pos=0.75,below]{Return} node[right]{$-h$};
  
\draw (rec2) |- ++(8,-4) coordinate(Nnbuy)node[right]{$0$} ;
\node[above] at (Nbuy|-Nnbuy) {Don't buy} ;

 \node[below right,align=left,inner xsep=0,inner ysep=5pt]at (rec1.south west){Retailer \\ announces \\ $P$ and $T$};
 % Red dashed lines
 \draw[dashed,red] (2,4) -- (2,-5)(5,4) -- (5,-5)(10.75,4) -- (10.75,-5);
 
 % Top and bottom labels
 \node at (0.75,-4.75){\textbf{Retailer}};
 \node at (3.5,-4.75){\textbf{Consumer}};
 \node at (7.875,-4.75){\textbf{Consumer}};
 \node at (0.75,3.75){\textbf{Stage I}};
 \node at (3.5,3.75){\textbf{Stage II}};
 \node at (7.875,3.75){\textbf{Stage III}};
 \node at (11.5,3.75){\textbf{Utility}};
\end{tikzpicture}
 

\end{document}

Which yields the following result: enter image description here

You can check this tutorial about drawing block diagrams .

3
  • 1
    Thank you so much. It is great – Katatonia Feb 18 at 3:38
  • You're welcome :) – LaTeXdraw-com Feb 18 at 9:07
  • Dear @LaTeXdraw-com, Could you please let me know how it is possible to fix the position of text at the beginning of the arrow? For example, I removed the box after "Match" and extended the line, and then, the word "Match" moved and it is not aligend with "Mismatch". Thanks One more thing, why are some right arrow and some lines? – Katatonia Apr 25 at 6:04
2

This is my try of drawing the figure using the istgame package.

enter image description here

\documentclass[tikz]{standalone}
    
\usepackage{istgame}
\usepackage{makecell}

\begin{document}

\begin{istgame}[edge from parent path={(\tikzparentnode) |- (\tikzchildnode.west)}]

\setistgrowdirection'{east}
\setistmathTF001
\setxtarrowtips{latex}[very thick]

\setistNewNodeStyle{init}[rectangle,fill=gray]{1cm}
\setistNewNodeStyle{rect}[rectangle]{1cm}
\setistNewNodeStyle{circ}{1cm}

\xtdistance{25mm}{30mm}
\istroot(0)[init]<[xshift=3mm]-90>{\makecell[l]{Retailer\\announces\\$P$ and $T$}}
  \istb[->-=.75] 
  \endist
\istrooto(1)(0-1)[rect]
  \istb<grow=0>[->-=.75]{Buy}[above,pos=.65] 
  \istb<sibling distance=60mm,level distance=65mm>{Don't buy}[above,pos=.57]{0}
  \endist
\xtdistance{25mm}{30mm}
\istrooto(2)(1-1)[circ]
  \istB[->-=.93]{Match}[above,pos=.72]{$m$}[below,pos=.72]
  \istB[->-=.93]{Mismatch}[below,pos=.72]{$1-m$}[above,pos=.72]
  \endist
\xtdistance{15mm}{15mm}
\istrooto(3a)(2-1)[rect]
  \istb{Keep}[above,pos=.75]{v-P}
  \istb{Return}[below,pos=.75]{vc-h}
  \endist
\istrooto(3b)(2-2)[rect]
  \istb{Keep}[above,pos=.75]{s-P}
  \istb{Return}[below,pos=.75]{-h}
  \endist

\xtTimeLineV[dashed]([xshift=-7mm]1){3.5}{-4}{Stage I}[left=5mm]
\xtTimeLineV[dashed]([xshift=-7mm]2){3.5}{-4}{Stage II}[left=5mm]
\xtTimeLineV[dashed]([xshift=-1.5mm]3a-1){3.5}{-4}{Stage III}[left=15mm]
\xtTimeLineV[draw=none]([xshift=-1.5mm]3a-1){3.5}{-4}{\underline{Utility}}[right=2mm]
\xtTimeLineV'[draw=none]([xshift=-7mm]1){3.5}{-4}{Retailer}[left=5mm]
\xtTimeLineV'[draw=none]([xshift=-7mm]2){3.5}{-4}{Consumer}[left=5mm]
\xtTimeLineV'[draw=none]([xshift=-1.5mm]3a-1){3.5}{-4}{Consumer}[left=15mm]

\end{istgame}

\end{document}
2

A solution that uses child nodes.

\documentclass[tikz,border=3.14159cm]{standalone}
\usetikzlibrary{arrows.meta,positioning}

\begin{document}

\begin{tikzpicture}
    [grow=right, scale=1.,font=\normalsize,
    edge from parent path={(\tikzparentnode) |- (\tikzchildnode.west)},
    edge from parent/.style={draw,-{Stealth[scale=2]}},
    level distance=3cm,
    sibling distance=3cm,
    level 4/.style={sibling distance=1.5cm},
    auto,transform shape,
    on grid]
    
    \tikzset{every node/.style={rectangle,minimum width=1cm,minimum height=1cm,draw}}
    \tikzset{edgenode/.style={draw=none,minimum height=0pt,rectangle,inner sep=3pt,pos=.75}}
    \tikzset{legend/.style={draw=none,minimum height=0pt,rectangle,inner sep=3pt}}
    
    \node[fill=gray](retailer) {}
        child { node (consumer){} 
            child { node[circle,fill=white] { }
                child { node {}
                    child { node[draw=none] {$-h$}
                    edge from parent node[edgenode,below] {Return}}
                    child { node[draw=none] {$s-P$}
                    edge from parent node[edgenode,above] {Keep}}
                edge from parent node[edgenode,below] {Mismatch} node[edgenode,above] {$1-m$}}
                child { node {}
                    child { node[draw=none] {$\nu c-h$}
                    edge from parent node[edgenode,below] {Return}}
                    child { node[draw=none] {$\nu-P$}
                    edge from parent node[edgenode,above] {Keep}}
                edge from parent node[edgenode,above] {Match} node[edgenode,below] {$m$}}           
            edge from parent node[edgenode,above] {Buy}}
        };
    
    \draw[edge from parent] (consumer) --++ (0,-4) --++ (8.5,0) node[edgenode,pos=.12,above] {Don't buy} node[anchor=west,draw=none,at end] {0};
    \draw[dashed]   (2,4) --++ (0,-9)
                    (5,4) --++ (0,-9)
                    (11,4) --++ (0,-9);
    \node[legend] at (0,-4.5) {Retailer};
    \node[legend] at (3.5,-4.5) {Consumer};
    \node[legend] at (8,-4.5) {Consumer};
    \node[legend] at (0,3.5) {Stage I};
    \node[legend] at (3.5,3.5) {Stage II};
    \node[legend] at (8,3.5) {Stage III};
    \node[legend] at (12,3.5) {Utility};
    \node[legend,text width=2cm,align=center] at (0,-1.3) {Retailer announces P and T};
\end{tikzpicture}
\end{document}

enter image description here

EDIT I edit my post without deleting the first version. Here's an improved version without the flaws of the first rapid script.

\documentclass[tikz,border=3.14159mm]{standalone}
\usetikzlibrary{arrows.meta,positioning}

\begin{document}

\begin{tikzpicture}
    [line width=.5pt,
    grow=right, scale=1.,font=\normalsize,
    edge from parent path={(\tikzparentnode) |- (\tikzchildnode.west)},
    edge from parent/.style={draw,-{Stealth[scale=1.5]}},
    level distance=3cm,
    sibling distance=3cm,
    level 4/.style={sibling distance=1.5cm},
    auto,transform shape,
    on grid]
    
    \tikzset{every node/.style={rectangle,minimum width=1cm,minimum height=1cm,draw}}
    \tikzset{edgenode/.style={draw=none,minimum height=0pt,rectangle,inner sep=3pt,pos=.75}}
    \tikzset{legend/.style={draw=none,minimum height=0pt,rectangle,inner sep=3pt}}
    
    \node[fill=gray](retailer) {}
        child { node (consumer){} 
            %
            child { node[circle] { }
            %
                child { node {}
                    %
                    child { node[draw=none] {$-h$}
                    edge from parent[-] node[edgenode,below] {Return}}
                    %
                    child { node[draw=none] {$s-P$}
                    edge from parent[-] node[edgenode,above] {Keep}}
                    %
                edge from parent node[edgenode,below] {Mismatch} node[edgenode,above] {$1-m$}}
                child { node {}
                    %
                    child { node[draw=none] {$\nu c-h$}
                    edge from parent[-] node[edgenode,below] {Return}}
                    %
                    child { node[draw=none] {$\nu-P$}
                    edge from parent[-] node[edgenode,above] {Keep}}
                    %
                edge from parent node[edgenode,above] {Match} node[edgenode,below] {$m$}}                   %
            edge from parent node[edgenode,above] {Buy}}
        };
    
    \draw (consumer) |- (11.5,-4) node[edgenode,pos=.56,above] {Don't buy} node[anchor=west,draw=none,at end] {0};
    
    \draw[dashed]   (2,4) --++ (0,-9)
                    (5,4) --++ (0,-9)
                    (11,4) --++ (0,-9);

    \node[legend] at (0,-4.5) {Retailer};
    \node[legend] at (3.5,-4.5) {Consumer};
    \node[legend] at (8,-4.5) {Consumer};
    \node[legend] at (0,3.5) {Stage I};
    \node[legend] at (3.5,3.5) {Stage II};
    \node[legend] at (8,3.5) {Stage III};
    \node[legend] at (12,3.5) {Utility};
    \node[below = 1.2cm of retailer,legend,text width=2cm,align=center] {Retailer announces P and T};
\end{tikzpicture}
\end{document}

v2

1
  • Just edited my post to add a V2. – SebGlav Feb 18 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.