Draw tree in tikzHow to Center Titles in Forest Trees?Tikz-PGF: Draw integral test plotTikz how to draw a...
Convert an array of objects to array of the objects' values
I've given my players a lot of magic items. Is it reasonable for me to give them harder encounters?
The need of reserving one's ability in job interviews
If nine coins are tossed, what is the probability that the number of heads is even?
3.5% Interest Student Loan or use all of my savings on Tuition?
Why aren't there more gauls like Obelix?
A bug in Excel? Conditional formatting for marking duplicates also highlights unique value
Deal the cards to the players
Do natural melee weapons (from racial traits) trigger Improved Divine Smite?
Error in TransformedField
What is the oldest European royal house?
Can a space-faring robot still function over a billion years?
ESPP--any reason not to go all in?
Dukha vs legitimate need
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
Is there a way to find out the age of climbing ropes?
Can a Mimic (container form) actually hold loot?
What is Tony Stark injecting into himself in Iron Man 3?
Why do we call complex numbers “numbers” but we don’t consider 2 vectors numbers?
What does "rhumatis" mean?
“I had a flat in the centre of town, but I didn’t like living there, so …”
What is "desert glass" and what does it do to the PCs?
Computing the volume of a simplex-like object with constraints
Naming Characters after Friends/Family
Draw tree in tikz
How to Center Titles in Forest Trees?Tikz-PGF: Draw integral test plotTikz how to draw a conditional iterative statementHorizontal decision tree in TikZDrawing Tree Diagram using TikzAbstract word embeddings with TikZDrawing a funnel with Tikzconcept diagram using tikzHow to draw this picture/figure with TikZ?TikZ overlay over png imageCreating this vectorised watermark in TikZ
I would like to replicate this powerpoint sketch in LaTeX. I tried it with tikz, but didn't come to a result.
Any help appreciated!
tikz-pgf pstricks
add a comment |
I would like to replicate this powerpoint sketch in LaTeX. I tried it with tikz, but didn't come to a result.
Any help appreciated!
tikz-pgf pstricks
5
Please share your attempt with us as a MWE to help us help you.
– TeXnician
Jan 3 at 12:38
2
I would use theistgame
package for drawing such trees. It's very well documented and is designed specifically for game trees.
– Alan Munn
Jan 3 at 13:05
add a comment |
I would like to replicate this powerpoint sketch in LaTeX. I tried it with tikz, but didn't come to a result.
Any help appreciated!
tikz-pgf pstricks
I would like to replicate this powerpoint sketch in LaTeX. I tried it with tikz, but didn't come to a result.
Any help appreciated!
tikz-pgf pstricks
tikz-pgf pstricks
edited Jan 4 at 3:50
marmot
106k5129243
106k5129243
asked Jan 3 at 12:34
HazardsHazards
775
775
5
Please share your attempt with us as a MWE to help us help you.
– TeXnician
Jan 3 at 12:38
2
I would use theistgame
package for drawing such trees. It's very well documented and is designed specifically for game trees.
– Alan Munn
Jan 3 at 13:05
add a comment |
5
Please share your attempt with us as a MWE to help us help you.
– TeXnician
Jan 3 at 12:38
2
I would use theistgame
package for drawing such trees. It's very well documented and is designed specifically for game trees.
– Alan Munn
Jan 3 at 13:05
5
5
Please share your attempt with us as a MWE to help us help you.
– TeXnician
Jan 3 at 12:38
Please share your attempt with us as a MWE to help us help you.
– TeXnician
Jan 3 at 12:38
2
2
I would use the
istgame
package for drawing such trees. It's very well documented and is designed specifically for game trees.– Alan Munn
Jan 3 at 13:05
I would use the
istgame
package for drawing such trees. It's very well documented and is designed specifically for game trees.– Alan Munn
Jan 3 at 13:05
add a comment |
4 Answers
4
active
oldest
votes
Apart from the istgame
package, which has been suggested in Alan Munn's comment, there is also the forest
package which is based on TikZ and can be used in order to draw general trees. I base my answer on this answer by @cfr, who will be able to provide a much more elegant version of this if she sees this. However, I think that already this answer illustrates some of the strengths of forest, namely that you can do things programmatically like e.g. the placement of the edge label
s, i.e. you do not have to do the repetitions by hand as in other approaches, and, what is perhaps more important, if you decide to change the typesetting of, say acc
to be upright (what I want to recommend), you do it once and not over and over.
documentclass{article}
usepackage{forest}
begin{document}
begin{forest}
/tikz/my edge label/.style={inner sep=5pt, midway},
/tikz/c/.style n args={2}{circle,inner sep=3pt,draw,fill=#1,label=above
right:$#2$},
trian/.style={tikz={draw[dashed]() -- ++(1,-1) --++({-2cm-3*sqrt(2)*1pt},0) -- ();}},
for tree={
l sep=4em,
s sep=8em,
anchor=center,
before typesetting nodes={
if n'=1{
if n=1{}{edge label/.wrap value={noexpand node [my edge label,right]
{$not$} }}
}{
edge label/.wrap value={noexpand node [my edge label,left] {$acc$} }
},
},
if n children=0{}{
circle,
draw,
}
}
[,c={black}{x_1},trian
[,c={cyan}{{(a^0,1-a^0)}},label=below:{$x_2$}
[{$(a^0,1-a^0)$}]
[,c={cyan}{{x_3}},trian
[,c={black}{{(a^1,1-a^1)}},label=below:{$x_4$}
[{$bigl(delta_1a^1,delta_2(1-a^1)bigr)$}]
[,c={black}{{x_5}},trian
[,c={cyan}{{(a^2,1-a^2)}},label=below:{$x_6$}
[{$bigl((delta_1)^2a^1,(delta_2)^2(1-a^1)bigr)$}]
[{$(0,0)$}]
]
]
]
]
]
]
end{forest}
end{document}
add a comment |
Here is a starter. Run with xelatex
or use auto-pst-pdf
:
documentclass{article}
usepackage{pst-tree}
newcommandTriangle[1][black]{TRIANGLE[#1]}
defTRIANGLE[#1](#2){rput[t](#2){%
pspolygon[linestyle=dashed](0,0)(-1.3,-1.3)(1.3,-1.3)}%
pscircle[fillstyle=solid,fillcolor=#1](#2){5pt}}
begin{document}
psset{treesep=2,levelsep=2}
psTree{Tdot[dotsize=10pt,name=x1]}%
psTree{TC[radius=5pt,name=x2]_[tpos=0.8]{$(a^0,1-a^0)$}}
TR[name=x2l]{$(a^0,1-a^0)$}^{$acc$}
psTree{TC[radius=5pt,name=x3]_{$not$}}
Tdot[dotsize=10pt,name=x4]_[tpos=0.8]{$(a^1,1-a^1)$}
endpsTree
endpsTree
endpsTree
uput{10pt}[20](x1){$x_1$}%
Triangle(x1)%
uput{10pt}[-90](x2){$x_2$}%
uput{10pt}[0](x3){$x_3$}%
Triangle[cyan!40](x3)%
end{document}
add a comment |
Here's a version using the istgame
package which is designed specifically for drawing game theory trees. The package doesn't have a dashed stye for the dashed continuum of branches, so I've created a new command modelled on the existing istgame
continuum of branches macro istcntm
macro. This macro is called istcntmx
and allows you pass TikZ options to the triangle. Its syntax is otherwise identical.
documentclass{article}
usepackage{istgame}
makeatletter
ExplSyntaxOn
NewDocumentCommand istcntmx
{ t' O{istdefault@grow} r() D(){0,0} O{dashed} G{} D+.{cntmdefault@levdist}D.+{cntmdefault@sibdist} }
{
IfBooleanTF {#1}
{
istCntmRootx' [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
{
istCntmRootx [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
}
NewDocumentCommandistCntmRootx{t'O{south}r()D(){0,0}O{dashed}G{.5}D+.{cntmdefault@levdist}D.+{cntmdefault@sibdist}}
{
IfBooleanTF {#1}
{
cntmdistance{#7}{#8}
tikzset{level~1/.style={level~distance=cntmlevdist,sibling~ distance=cntmsibdist]}}
setistNullNodeStyle[]{istdefault@nullnodesize}[]
node (#3) at (#4) [null~node] {} [xtgrowprime=#2] child[#5] child[#5];
draw [#5] (#3) -- (#3-1) -- (#3-2);
setistNullNodeStyle{istdefault@nullnodesize}
}
{
cntmdistance{#7}{#8}
tikzset{level~1/.style={level~distance=cntmlevdist,sibling~ distance=cntmsibdist]}}
setistNullNodeStyle[]{istdefault@nullnodesize}[]
node (#3) at (#4) [null~node] {} [xtgrow=#2] child[#5] child[#5];
draw [#5] (#3) -- (#3-1) -- (#3-2);
setistNullNodeStyle{istdefault@nullnodesize}
}
}
ExplSyntaxOff
makeatother
setistDecisionNodeStyle[black]{6pt}
tikzset{blue node/.style={draw=blue,fill=cyan!50,circle=6pt}}
begin{document}
begin{istgame}
xtdistance{20mm}{35mm}
istcntmx(0)+15mm..25mm+
istroot(0)
istb*{}[]{(a^{0},1-a^{0})}[[xshift=10pt,yshift=-8pt]right]
endist
istroot(1)(0-1)[blue node]<[yshift=-3pt]below>{$x_{2}$}
istb{acc}[al]{(a^{0},1-a^{0})} istb{not}[ar]{x_{3}}[r]
endist
istroot(2)(1-2)[blue node]
istcntmx(0-1)(1-2)+15mm..25mm+
istb*{}[]{(a^{1},1-a^{1})}[[xshift=10pt,yshift=-8pt]right]
endist
istroot(3)(2-1)<[yshift=-3pt]below>{$x_{4}$}
istb{acc}[al]{(delta_{1}a^{1},delta_{2}(1-a^{1}))} istb*{not}[ar]
endist
end{istgame}
end{document}
add a comment |
This is another example of using the istgame
package.
istgame version v2.0
With the version 2, you can use a new macro istroocntm, which is simpler (if used by defaults) and more powerful than using (obsolete) istcntm and istroot. You can control the features of a continuum triangle using cntmpreset(*).
documentclass{standalone}
usepackage{istgame}
begin{document}
begin{istgame}[font=scriptsize]
% presets
tikzset{odd node/.style={decision node,minimum size=6pt}}
tikzset{even node/.style={oval node,fill=cyan!50,minimum size=6pt}}
% game tree
cntmdistance*{20mm}{35mm}
cntmpreset*[densely dashed]{.6}
istrootcntm(1a)[odd node]<15>{$x_1$}
istb{(a^0,1-a^0)}[right,near end] endist
istroot(2)(1a-1)[even node]<-90>{$x_2$}
istb{acc}[al]{left(a^0,1-a^0right)}
istb{not}[ar]
endist
istrootcntm(2a)(2-2)[even node]<0>{$x_3$}
istb{(a^2,1-a^2)}[right,near end] endist
istroot(3)(2a-1)[odd node]<-90>{$x_4$}
istb{acc}[al]{left(delta_1 a^1,delta_2(1-a^1)right)}
istb{not}[ar]
endist
istrootcntm(3a)(3-2)[odd node]<0>{$x_5$}
istb{(a^2,1-a^2)}[right,near end] endist
istroot(4)(3a-1)[even node]<-90>{$x_6$}
istb{acc}[al]{left((delta_1)^2a^2,(delta_2)^2(1-a^2)right)}
istb{not}[ar]{(0,0)}
endist
end{istgame}
end{document}
original answer (istgame v1.0)
I borrowed distances and colors from Alan's answer, which will work in every direction of tree growing.
(I am working on an update for the istgame package, hoping that drawing game trees will be a little more easier in various situations. I have also spent some time to new macros related to continua of branches.)
documentclass{standalone}
usepackage{istgame}
begin{document}
begin{istgame}[scale=1.2,font=scriptsize]
% presets
tikzset{odd node/.style={decision node,minimum size=6pt}}
tikzset{even node/.style={oval node,fill=cyan!50,minimum size=6pt}}
NewDocumentCommandDASHEDcntm{ r() r() G{} O{below right} }
{
istroot(#1)(#2)[null node]+15mm..{(7/4)*15mm}+
istb[dashed] istb[dashed] endist
draw [dashed] (#1-1) -- (#1-2);
xtPayoff($(#1-1)!.5!(#1-2)$){#3}[#4]
}
% game tree
xtdistance{20mm}{35mm}
DASHEDcntm(1a)(0,0){(a^0,1-a^0)}
istroot(1a)[odd node]<15>{$x_1$} istb endist
istroot(2)(1a-1)[even node]<-90>{$x_2$}
istb{acc}[al]{left(a^0,1-a^0right)}
istb{not}[ar]
endist
DASHEDcntm(2a)(2-2){(a^1,1-a^1)}
istroot(2a)(2-2)[even node]<0>{$x_3$} istb endist
istroot(3)(2a-1)[odd node]<-90>{$x_4$}
istb{acc}[al]{left(delta_1 a^1,delta_2(1-a^1)right)}
istb{not}[ar]
endist
DASHEDcntm(3a)(3-2){(a^2,1-a^2)}
istroot(3a)(3-2)[odd node]<0>{$x_5$} istb endist
istroot(4)(3a-1)[even node]<-90>{$x_6$}
istb{acc}[al]{left((delta_1)^2a^2,(delta_2)^2(1-a^2)right)}
istb{not}[ar]{(0,0)}
endist
end{istgame}
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468397%2fdraw-tree-in-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Apart from the istgame
package, which has been suggested in Alan Munn's comment, there is also the forest
package which is based on TikZ and can be used in order to draw general trees. I base my answer on this answer by @cfr, who will be able to provide a much more elegant version of this if she sees this. However, I think that already this answer illustrates some of the strengths of forest, namely that you can do things programmatically like e.g. the placement of the edge label
s, i.e. you do not have to do the repetitions by hand as in other approaches, and, what is perhaps more important, if you decide to change the typesetting of, say acc
to be upright (what I want to recommend), you do it once and not over and over.
documentclass{article}
usepackage{forest}
begin{document}
begin{forest}
/tikz/my edge label/.style={inner sep=5pt, midway},
/tikz/c/.style n args={2}{circle,inner sep=3pt,draw,fill=#1,label=above
right:$#2$},
trian/.style={tikz={draw[dashed]() -- ++(1,-1) --++({-2cm-3*sqrt(2)*1pt},0) -- ();}},
for tree={
l sep=4em,
s sep=8em,
anchor=center,
before typesetting nodes={
if n'=1{
if n=1{}{edge label/.wrap value={noexpand node [my edge label,right]
{$not$} }}
}{
edge label/.wrap value={noexpand node [my edge label,left] {$acc$} }
},
},
if n children=0{}{
circle,
draw,
}
}
[,c={black}{x_1},trian
[,c={cyan}{{(a^0,1-a^0)}},label=below:{$x_2$}
[{$(a^0,1-a^0)$}]
[,c={cyan}{{x_3}},trian
[,c={black}{{(a^1,1-a^1)}},label=below:{$x_4$}
[{$bigl(delta_1a^1,delta_2(1-a^1)bigr)$}]
[,c={black}{{x_5}},trian
[,c={cyan}{{(a^2,1-a^2)}},label=below:{$x_6$}
[{$bigl((delta_1)^2a^1,(delta_2)^2(1-a^1)bigr)$}]
[{$(0,0)$}]
]
]
]
]
]
]
end{forest}
end{document}
add a comment |
Apart from the istgame
package, which has been suggested in Alan Munn's comment, there is also the forest
package which is based on TikZ and can be used in order to draw general trees. I base my answer on this answer by @cfr, who will be able to provide a much more elegant version of this if she sees this. However, I think that already this answer illustrates some of the strengths of forest, namely that you can do things programmatically like e.g. the placement of the edge label
s, i.e. you do not have to do the repetitions by hand as in other approaches, and, what is perhaps more important, if you decide to change the typesetting of, say acc
to be upright (what I want to recommend), you do it once and not over and over.
documentclass{article}
usepackage{forest}
begin{document}
begin{forest}
/tikz/my edge label/.style={inner sep=5pt, midway},
/tikz/c/.style n args={2}{circle,inner sep=3pt,draw,fill=#1,label=above
right:$#2$},
trian/.style={tikz={draw[dashed]() -- ++(1,-1) --++({-2cm-3*sqrt(2)*1pt},0) -- ();}},
for tree={
l sep=4em,
s sep=8em,
anchor=center,
before typesetting nodes={
if n'=1{
if n=1{}{edge label/.wrap value={noexpand node [my edge label,right]
{$not$} }}
}{
edge label/.wrap value={noexpand node [my edge label,left] {$acc$} }
},
},
if n children=0{}{
circle,
draw,
}
}
[,c={black}{x_1},trian
[,c={cyan}{{(a^0,1-a^0)}},label=below:{$x_2$}
[{$(a^0,1-a^0)$}]
[,c={cyan}{{x_3}},trian
[,c={black}{{(a^1,1-a^1)}},label=below:{$x_4$}
[{$bigl(delta_1a^1,delta_2(1-a^1)bigr)$}]
[,c={black}{{x_5}},trian
[,c={cyan}{{(a^2,1-a^2)}},label=below:{$x_6$}
[{$bigl((delta_1)^2a^1,(delta_2)^2(1-a^1)bigr)$}]
[{$(0,0)$}]
]
]
]
]
]
]
end{forest}
end{document}
add a comment |
Apart from the istgame
package, which has been suggested in Alan Munn's comment, there is also the forest
package which is based on TikZ and can be used in order to draw general trees. I base my answer on this answer by @cfr, who will be able to provide a much more elegant version of this if she sees this. However, I think that already this answer illustrates some of the strengths of forest, namely that you can do things programmatically like e.g. the placement of the edge label
s, i.e. you do not have to do the repetitions by hand as in other approaches, and, what is perhaps more important, if you decide to change the typesetting of, say acc
to be upright (what I want to recommend), you do it once and not over and over.
documentclass{article}
usepackage{forest}
begin{document}
begin{forest}
/tikz/my edge label/.style={inner sep=5pt, midway},
/tikz/c/.style n args={2}{circle,inner sep=3pt,draw,fill=#1,label=above
right:$#2$},
trian/.style={tikz={draw[dashed]() -- ++(1,-1) --++({-2cm-3*sqrt(2)*1pt},0) -- ();}},
for tree={
l sep=4em,
s sep=8em,
anchor=center,
before typesetting nodes={
if n'=1{
if n=1{}{edge label/.wrap value={noexpand node [my edge label,right]
{$not$} }}
}{
edge label/.wrap value={noexpand node [my edge label,left] {$acc$} }
},
},
if n children=0{}{
circle,
draw,
}
}
[,c={black}{x_1},trian
[,c={cyan}{{(a^0,1-a^0)}},label=below:{$x_2$}
[{$(a^0,1-a^0)$}]
[,c={cyan}{{x_3}},trian
[,c={black}{{(a^1,1-a^1)}},label=below:{$x_4$}
[{$bigl(delta_1a^1,delta_2(1-a^1)bigr)$}]
[,c={black}{{x_5}},trian
[,c={cyan}{{(a^2,1-a^2)}},label=below:{$x_6$}
[{$bigl((delta_1)^2a^1,(delta_2)^2(1-a^1)bigr)$}]
[{$(0,0)$}]
]
]
]
]
]
]
end{forest}
end{document}
Apart from the istgame
package, which has been suggested in Alan Munn's comment, there is also the forest
package which is based on TikZ and can be used in order to draw general trees. I base my answer on this answer by @cfr, who will be able to provide a much more elegant version of this if she sees this. However, I think that already this answer illustrates some of the strengths of forest, namely that you can do things programmatically like e.g. the placement of the edge label
s, i.e. you do not have to do the repetitions by hand as in other approaches, and, what is perhaps more important, if you decide to change the typesetting of, say acc
to be upright (what I want to recommend), you do it once and not over and over.
documentclass{article}
usepackage{forest}
begin{document}
begin{forest}
/tikz/my edge label/.style={inner sep=5pt, midway},
/tikz/c/.style n args={2}{circle,inner sep=3pt,draw,fill=#1,label=above
right:$#2$},
trian/.style={tikz={draw[dashed]() -- ++(1,-1) --++({-2cm-3*sqrt(2)*1pt},0) -- ();}},
for tree={
l sep=4em,
s sep=8em,
anchor=center,
before typesetting nodes={
if n'=1{
if n=1{}{edge label/.wrap value={noexpand node [my edge label,right]
{$not$} }}
}{
edge label/.wrap value={noexpand node [my edge label,left] {$acc$} }
},
},
if n children=0{}{
circle,
draw,
}
}
[,c={black}{x_1},trian
[,c={cyan}{{(a^0,1-a^0)}},label=below:{$x_2$}
[{$(a^0,1-a^0)$}]
[,c={cyan}{{x_3}},trian
[,c={black}{{(a^1,1-a^1)}},label=below:{$x_4$}
[{$bigl(delta_1a^1,delta_2(1-a^1)bigr)$}]
[,c={black}{{x_5}},trian
[,c={cyan}{{(a^2,1-a^2)}},label=below:{$x_6$}
[{$bigl((delta_1)^2a^1,(delta_2)^2(1-a^1)bigr)$}]
[{$(0,0)$}]
]
]
]
]
]
]
end{forest}
end{document}
answered Jan 4 at 1:34
marmotmarmot
106k5129243
106k5129243
add a comment |
add a comment |
Here is a starter. Run with xelatex
or use auto-pst-pdf
:
documentclass{article}
usepackage{pst-tree}
newcommandTriangle[1][black]{TRIANGLE[#1]}
defTRIANGLE[#1](#2){rput[t](#2){%
pspolygon[linestyle=dashed](0,0)(-1.3,-1.3)(1.3,-1.3)}%
pscircle[fillstyle=solid,fillcolor=#1](#2){5pt}}
begin{document}
psset{treesep=2,levelsep=2}
psTree{Tdot[dotsize=10pt,name=x1]}%
psTree{TC[radius=5pt,name=x2]_[tpos=0.8]{$(a^0,1-a^0)$}}
TR[name=x2l]{$(a^0,1-a^0)$}^{$acc$}
psTree{TC[radius=5pt,name=x3]_{$not$}}
Tdot[dotsize=10pt,name=x4]_[tpos=0.8]{$(a^1,1-a^1)$}
endpsTree
endpsTree
endpsTree
uput{10pt}[20](x1){$x_1$}%
Triangle(x1)%
uput{10pt}[-90](x2){$x_2$}%
uput{10pt}[0](x3){$x_3$}%
Triangle[cyan!40](x3)%
end{document}
add a comment |
Here is a starter. Run with xelatex
or use auto-pst-pdf
:
documentclass{article}
usepackage{pst-tree}
newcommandTriangle[1][black]{TRIANGLE[#1]}
defTRIANGLE[#1](#2){rput[t](#2){%
pspolygon[linestyle=dashed](0,0)(-1.3,-1.3)(1.3,-1.3)}%
pscircle[fillstyle=solid,fillcolor=#1](#2){5pt}}
begin{document}
psset{treesep=2,levelsep=2}
psTree{Tdot[dotsize=10pt,name=x1]}%
psTree{TC[radius=5pt,name=x2]_[tpos=0.8]{$(a^0,1-a^0)$}}
TR[name=x2l]{$(a^0,1-a^0)$}^{$acc$}
psTree{TC[radius=5pt,name=x3]_{$not$}}
Tdot[dotsize=10pt,name=x4]_[tpos=0.8]{$(a^1,1-a^1)$}
endpsTree
endpsTree
endpsTree
uput{10pt}[20](x1){$x_1$}%
Triangle(x1)%
uput{10pt}[-90](x2){$x_2$}%
uput{10pt}[0](x3){$x_3$}%
Triangle[cyan!40](x3)%
end{document}
add a comment |
Here is a starter. Run with xelatex
or use auto-pst-pdf
:
documentclass{article}
usepackage{pst-tree}
newcommandTriangle[1][black]{TRIANGLE[#1]}
defTRIANGLE[#1](#2){rput[t](#2){%
pspolygon[linestyle=dashed](0,0)(-1.3,-1.3)(1.3,-1.3)}%
pscircle[fillstyle=solid,fillcolor=#1](#2){5pt}}
begin{document}
psset{treesep=2,levelsep=2}
psTree{Tdot[dotsize=10pt,name=x1]}%
psTree{TC[radius=5pt,name=x2]_[tpos=0.8]{$(a^0,1-a^0)$}}
TR[name=x2l]{$(a^0,1-a^0)$}^{$acc$}
psTree{TC[radius=5pt,name=x3]_{$not$}}
Tdot[dotsize=10pt,name=x4]_[tpos=0.8]{$(a^1,1-a^1)$}
endpsTree
endpsTree
endpsTree
uput{10pt}[20](x1){$x_1$}%
Triangle(x1)%
uput{10pt}[-90](x2){$x_2$}%
uput{10pt}[0](x3){$x_3$}%
Triangle[cyan!40](x3)%
end{document}
Here is a starter. Run with xelatex
or use auto-pst-pdf
:
documentclass{article}
usepackage{pst-tree}
newcommandTriangle[1][black]{TRIANGLE[#1]}
defTRIANGLE[#1](#2){rput[t](#2){%
pspolygon[linestyle=dashed](0,0)(-1.3,-1.3)(1.3,-1.3)}%
pscircle[fillstyle=solid,fillcolor=#1](#2){5pt}}
begin{document}
psset{treesep=2,levelsep=2}
psTree{Tdot[dotsize=10pt,name=x1]}%
psTree{TC[radius=5pt,name=x2]_[tpos=0.8]{$(a^0,1-a^0)$}}
TR[name=x2l]{$(a^0,1-a^0)$}^{$acc$}
psTree{TC[radius=5pt,name=x3]_{$not$}}
Tdot[dotsize=10pt,name=x4]_[tpos=0.8]{$(a^1,1-a^1)$}
endpsTree
endpsTree
endpsTree
uput{10pt}[20](x1){$x_1$}%
Triangle(x1)%
uput{10pt}[-90](x2){$x_2$}%
uput{10pt}[0](x3){$x_3$}%
Triangle[cyan!40](x3)%
end{document}
answered Jan 3 at 20:38
HerbertHerbert
275k25418731
275k25418731
add a comment |
add a comment |
Here's a version using the istgame
package which is designed specifically for drawing game theory trees. The package doesn't have a dashed stye for the dashed continuum of branches, so I've created a new command modelled on the existing istgame
continuum of branches macro istcntm
macro. This macro is called istcntmx
and allows you pass TikZ options to the triangle. Its syntax is otherwise identical.
documentclass{article}
usepackage{istgame}
makeatletter
ExplSyntaxOn
NewDocumentCommand istcntmx
{ t' O{istdefault@grow} r() D(){0,0} O{dashed} G{} D+.{cntmdefault@levdist}D.+{cntmdefault@sibdist} }
{
IfBooleanTF {#1}
{
istCntmRootx' [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
{
istCntmRootx [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
}
NewDocumentCommandistCntmRootx{t'O{south}r()D(){0,0}O{dashed}G{.5}D+.{cntmdefault@levdist}D.+{cntmdefault@sibdist}}
{
IfBooleanTF {#1}
{
cntmdistance{#7}{#8}
tikzset{level~1/.style={level~distance=cntmlevdist,sibling~ distance=cntmsibdist]}}
setistNullNodeStyle[]{istdefault@nullnodesize}[]
node (#3) at (#4) [null~node] {} [xtgrowprime=#2] child[#5] child[#5];
draw [#5] (#3) -- (#3-1) -- (#3-2);
setistNullNodeStyle{istdefault@nullnodesize}
}
{
cntmdistance{#7}{#8}
tikzset{level~1/.style={level~distance=cntmlevdist,sibling~ distance=cntmsibdist]}}
setistNullNodeStyle[]{istdefault@nullnodesize}[]
node (#3) at (#4) [null~node] {} [xtgrow=#2] child[#5] child[#5];
draw [#5] (#3) -- (#3-1) -- (#3-2);
setistNullNodeStyle{istdefault@nullnodesize}
}
}
ExplSyntaxOff
makeatother
setistDecisionNodeStyle[black]{6pt}
tikzset{blue node/.style={draw=blue,fill=cyan!50,circle=6pt}}
begin{document}
begin{istgame}
xtdistance{20mm}{35mm}
istcntmx(0)+15mm..25mm+
istroot(0)
istb*{}[]{(a^{0},1-a^{0})}[[xshift=10pt,yshift=-8pt]right]
endist
istroot(1)(0-1)[blue node]<[yshift=-3pt]below>{$x_{2}$}
istb{acc}[al]{(a^{0},1-a^{0})} istb{not}[ar]{x_{3}}[r]
endist
istroot(2)(1-2)[blue node]
istcntmx(0-1)(1-2)+15mm..25mm+
istb*{}[]{(a^{1},1-a^{1})}[[xshift=10pt,yshift=-8pt]right]
endist
istroot(3)(2-1)<[yshift=-3pt]below>{$x_{4}$}
istb{acc}[al]{(delta_{1}a^{1},delta_{2}(1-a^{1}))} istb*{not}[ar]
endist
end{istgame}
end{document}
add a comment |
Here's a version using the istgame
package which is designed specifically for drawing game theory trees. The package doesn't have a dashed stye for the dashed continuum of branches, so I've created a new command modelled on the existing istgame
continuum of branches macro istcntm
macro. This macro is called istcntmx
and allows you pass TikZ options to the triangle. Its syntax is otherwise identical.
documentclass{article}
usepackage{istgame}
makeatletter
ExplSyntaxOn
NewDocumentCommand istcntmx
{ t' O{istdefault@grow} r() D(){0,0} O{dashed} G{} D+.{cntmdefault@levdist}D.+{cntmdefault@sibdist} }
{
IfBooleanTF {#1}
{
istCntmRootx' [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
{
istCntmRootx [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
}
NewDocumentCommandistCntmRootx{t'O{south}r()D(){0,0}O{dashed}G{.5}D+.{cntmdefault@levdist}D.+{cntmdefault@sibdist}}
{
IfBooleanTF {#1}
{
cntmdistance{#7}{#8}
tikzset{level~1/.style={level~distance=cntmlevdist,sibling~ distance=cntmsibdist]}}
setistNullNodeStyle[]{istdefault@nullnodesize}[]
node (#3) at (#4) [null~node] {} [xtgrowprime=#2] child[#5] child[#5];
draw [#5] (#3) -- (#3-1) -- (#3-2);
setistNullNodeStyle{istdefault@nullnodesize}
}
{
cntmdistance{#7}{#8}
tikzset{level~1/.style={level~distance=cntmlevdist,sibling~ distance=cntmsibdist]}}
setistNullNodeStyle[]{istdefault@nullnodesize}[]
node (#3) at (#4) [null~node] {} [xtgrow=#2] child[#5] child[#5];
draw [#5] (#3) -- (#3-1) -- (#3-2);
setistNullNodeStyle{istdefault@nullnodesize}
}
}
ExplSyntaxOff
makeatother
setistDecisionNodeStyle[black]{6pt}
tikzset{blue node/.style={draw=blue,fill=cyan!50,circle=6pt}}
begin{document}
begin{istgame}
xtdistance{20mm}{35mm}
istcntmx(0)+15mm..25mm+
istroot(0)
istb*{}[]{(a^{0},1-a^{0})}[[xshift=10pt,yshift=-8pt]right]
endist
istroot(1)(0-1)[blue node]<[yshift=-3pt]below>{$x_{2}$}
istb{acc}[al]{(a^{0},1-a^{0})} istb{not}[ar]{x_{3}}[r]
endist
istroot(2)(1-2)[blue node]
istcntmx(0-1)(1-2)+15mm..25mm+
istb*{}[]{(a^{1},1-a^{1})}[[xshift=10pt,yshift=-8pt]right]
endist
istroot(3)(2-1)<[yshift=-3pt]below>{$x_{4}$}
istb{acc}[al]{(delta_{1}a^{1},delta_{2}(1-a^{1}))} istb*{not}[ar]
endist
end{istgame}
end{document}
add a comment |
Here's a version using the istgame
package which is designed specifically for drawing game theory trees. The package doesn't have a dashed stye for the dashed continuum of branches, so I've created a new command modelled on the existing istgame
continuum of branches macro istcntm
macro. This macro is called istcntmx
and allows you pass TikZ options to the triangle. Its syntax is otherwise identical.
documentclass{article}
usepackage{istgame}
makeatletter
ExplSyntaxOn
NewDocumentCommand istcntmx
{ t' O{istdefault@grow} r() D(){0,0} O{dashed} G{} D+.{cntmdefault@levdist}D.+{cntmdefault@sibdist} }
{
IfBooleanTF {#1}
{
istCntmRootx' [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
{
istCntmRootx [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
}
NewDocumentCommandistCntmRootx{t'O{south}r()D(){0,0}O{dashed}G{.5}D+.{cntmdefault@levdist}D.+{cntmdefault@sibdist}}
{
IfBooleanTF {#1}
{
cntmdistance{#7}{#8}
tikzset{level~1/.style={level~distance=cntmlevdist,sibling~ distance=cntmsibdist]}}
setistNullNodeStyle[]{istdefault@nullnodesize}[]
node (#3) at (#4) [null~node] {} [xtgrowprime=#2] child[#5] child[#5];
draw [#5] (#3) -- (#3-1) -- (#3-2);
setistNullNodeStyle{istdefault@nullnodesize}
}
{
cntmdistance{#7}{#8}
tikzset{level~1/.style={level~distance=cntmlevdist,sibling~ distance=cntmsibdist]}}
setistNullNodeStyle[]{istdefault@nullnodesize}[]
node (#3) at (#4) [null~node] {} [xtgrow=#2] child[#5] child[#5];
draw [#5] (#3) -- (#3-1) -- (#3-2);
setistNullNodeStyle{istdefault@nullnodesize}
}
}
ExplSyntaxOff
makeatother
setistDecisionNodeStyle[black]{6pt}
tikzset{blue node/.style={draw=blue,fill=cyan!50,circle=6pt}}
begin{document}
begin{istgame}
xtdistance{20mm}{35mm}
istcntmx(0)+15mm..25mm+
istroot(0)
istb*{}[]{(a^{0},1-a^{0})}[[xshift=10pt,yshift=-8pt]right]
endist
istroot(1)(0-1)[blue node]<[yshift=-3pt]below>{$x_{2}$}
istb{acc}[al]{(a^{0},1-a^{0})} istb{not}[ar]{x_{3}}[r]
endist
istroot(2)(1-2)[blue node]
istcntmx(0-1)(1-2)+15mm..25mm+
istb*{}[]{(a^{1},1-a^{1})}[[xshift=10pt,yshift=-8pt]right]
endist
istroot(3)(2-1)<[yshift=-3pt]below>{$x_{4}$}
istb{acc}[al]{(delta_{1}a^{1},delta_{2}(1-a^{1}))} istb*{not}[ar]
endist
end{istgame}
end{document}
Here's a version using the istgame
package which is designed specifically for drawing game theory trees. The package doesn't have a dashed stye for the dashed continuum of branches, so I've created a new command modelled on the existing istgame
continuum of branches macro istcntm
macro. This macro is called istcntmx
and allows you pass TikZ options to the triangle. Its syntax is otherwise identical.
documentclass{article}
usepackage{istgame}
makeatletter
ExplSyntaxOn
NewDocumentCommand istcntmx
{ t' O{istdefault@grow} r() D(){0,0} O{dashed} G{} D+.{cntmdefault@levdist}D.+{cntmdefault@sibdist} }
{
IfBooleanTF {#1}
{
istCntmRootx' [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
{
istCntmRootx [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
}
NewDocumentCommandistCntmRootx{t'O{south}r()D(){0,0}O{dashed}G{.5}D+.{cntmdefault@levdist}D.+{cntmdefault@sibdist}}
{
IfBooleanTF {#1}
{
cntmdistance{#7}{#8}
tikzset{level~1/.style={level~distance=cntmlevdist,sibling~ distance=cntmsibdist]}}
setistNullNodeStyle[]{istdefault@nullnodesize}[]
node (#3) at (#4) [null~node] {} [xtgrowprime=#2] child[#5] child[#5];
draw [#5] (#3) -- (#3-1) -- (#3-2);
setistNullNodeStyle{istdefault@nullnodesize}
}
{
cntmdistance{#7}{#8}
tikzset{level~1/.style={level~distance=cntmlevdist,sibling~ distance=cntmsibdist]}}
setistNullNodeStyle[]{istdefault@nullnodesize}[]
node (#3) at (#4) [null~node] {} [xtgrow=#2] child[#5] child[#5];
draw [#5] (#3) -- (#3-1) -- (#3-2);
setistNullNodeStyle{istdefault@nullnodesize}
}
}
ExplSyntaxOff
makeatother
setistDecisionNodeStyle[black]{6pt}
tikzset{blue node/.style={draw=blue,fill=cyan!50,circle=6pt}}
begin{document}
begin{istgame}
xtdistance{20mm}{35mm}
istcntmx(0)+15mm..25mm+
istroot(0)
istb*{}[]{(a^{0},1-a^{0})}[[xshift=10pt,yshift=-8pt]right]
endist
istroot(1)(0-1)[blue node]<[yshift=-3pt]below>{$x_{2}$}
istb{acc}[al]{(a^{0},1-a^{0})} istb{not}[ar]{x_{3}}[r]
endist
istroot(2)(1-2)[blue node]
istcntmx(0-1)(1-2)+15mm..25mm+
istb*{}[]{(a^{1},1-a^{1})}[[xshift=10pt,yshift=-8pt]right]
endist
istroot(3)(2-1)<[yshift=-3pt]below>{$x_{4}$}
istb{acc}[al]{(delta_{1}a^{1},delta_{2}(1-a^{1}))} istb*{not}[ar]
endist
end{istgame}
end{document}
edited Jan 4 at 5:21
answered Jan 4 at 3:32
Alan MunnAlan Munn
162k28431706
162k28431706
add a comment |
add a comment |
This is another example of using the istgame
package.
istgame version v2.0
With the version 2, you can use a new macro istroocntm, which is simpler (if used by defaults) and more powerful than using (obsolete) istcntm and istroot. You can control the features of a continuum triangle using cntmpreset(*).
documentclass{standalone}
usepackage{istgame}
begin{document}
begin{istgame}[font=scriptsize]
% presets
tikzset{odd node/.style={decision node,minimum size=6pt}}
tikzset{even node/.style={oval node,fill=cyan!50,minimum size=6pt}}
% game tree
cntmdistance*{20mm}{35mm}
cntmpreset*[densely dashed]{.6}
istrootcntm(1a)[odd node]<15>{$x_1$}
istb{(a^0,1-a^0)}[right,near end] endist
istroot(2)(1a-1)[even node]<-90>{$x_2$}
istb{acc}[al]{left(a^0,1-a^0right)}
istb{not}[ar]
endist
istrootcntm(2a)(2-2)[even node]<0>{$x_3$}
istb{(a^2,1-a^2)}[right,near end] endist
istroot(3)(2a-1)[odd node]<-90>{$x_4$}
istb{acc}[al]{left(delta_1 a^1,delta_2(1-a^1)right)}
istb{not}[ar]
endist
istrootcntm(3a)(3-2)[odd node]<0>{$x_5$}
istb{(a^2,1-a^2)}[right,near end] endist
istroot(4)(3a-1)[even node]<-90>{$x_6$}
istb{acc}[al]{left((delta_1)^2a^2,(delta_2)^2(1-a^2)right)}
istb{not}[ar]{(0,0)}
endist
end{istgame}
end{document}
original answer (istgame v1.0)
I borrowed distances and colors from Alan's answer, which will work in every direction of tree growing.
(I am working on an update for the istgame package, hoping that drawing game trees will be a little more easier in various situations. I have also spent some time to new macros related to continua of branches.)
documentclass{standalone}
usepackage{istgame}
begin{document}
begin{istgame}[scale=1.2,font=scriptsize]
% presets
tikzset{odd node/.style={decision node,minimum size=6pt}}
tikzset{even node/.style={oval node,fill=cyan!50,minimum size=6pt}}
NewDocumentCommandDASHEDcntm{ r() r() G{} O{below right} }
{
istroot(#1)(#2)[null node]+15mm..{(7/4)*15mm}+
istb[dashed] istb[dashed] endist
draw [dashed] (#1-1) -- (#1-2);
xtPayoff($(#1-1)!.5!(#1-2)$){#3}[#4]
}
% game tree
xtdistance{20mm}{35mm}
DASHEDcntm(1a)(0,0){(a^0,1-a^0)}
istroot(1a)[odd node]<15>{$x_1$} istb endist
istroot(2)(1a-1)[even node]<-90>{$x_2$}
istb{acc}[al]{left(a^0,1-a^0right)}
istb{not}[ar]
endist
DASHEDcntm(2a)(2-2){(a^1,1-a^1)}
istroot(2a)(2-2)[even node]<0>{$x_3$} istb endist
istroot(3)(2a-1)[odd node]<-90>{$x_4$}
istb{acc}[al]{left(delta_1 a^1,delta_2(1-a^1)right)}
istb{not}[ar]
endist
DASHEDcntm(3a)(3-2){(a^2,1-a^2)}
istroot(3a)(3-2)[odd node]<0>{$x_5$} istb endist
istroot(4)(3a-1)[even node]<-90>{$x_6$}
istb{acc}[al]{left((delta_1)^2a^2,(delta_2)^2(1-a^2)right)}
istb{not}[ar]{(0,0)}
endist
end{istgame}
end{document}
add a comment |
This is another example of using the istgame
package.
istgame version v2.0
With the version 2, you can use a new macro istroocntm, which is simpler (if used by defaults) and more powerful than using (obsolete) istcntm and istroot. You can control the features of a continuum triangle using cntmpreset(*).
documentclass{standalone}
usepackage{istgame}
begin{document}
begin{istgame}[font=scriptsize]
% presets
tikzset{odd node/.style={decision node,minimum size=6pt}}
tikzset{even node/.style={oval node,fill=cyan!50,minimum size=6pt}}
% game tree
cntmdistance*{20mm}{35mm}
cntmpreset*[densely dashed]{.6}
istrootcntm(1a)[odd node]<15>{$x_1$}
istb{(a^0,1-a^0)}[right,near end] endist
istroot(2)(1a-1)[even node]<-90>{$x_2$}
istb{acc}[al]{left(a^0,1-a^0right)}
istb{not}[ar]
endist
istrootcntm(2a)(2-2)[even node]<0>{$x_3$}
istb{(a^2,1-a^2)}[right,near end] endist
istroot(3)(2a-1)[odd node]<-90>{$x_4$}
istb{acc}[al]{left(delta_1 a^1,delta_2(1-a^1)right)}
istb{not}[ar]
endist
istrootcntm(3a)(3-2)[odd node]<0>{$x_5$}
istb{(a^2,1-a^2)}[right,near end] endist
istroot(4)(3a-1)[even node]<-90>{$x_6$}
istb{acc}[al]{left((delta_1)^2a^2,(delta_2)^2(1-a^2)right)}
istb{not}[ar]{(0,0)}
endist
end{istgame}
end{document}
original answer (istgame v1.0)
I borrowed distances and colors from Alan's answer, which will work in every direction of tree growing.
(I am working on an update for the istgame package, hoping that drawing game trees will be a little more easier in various situations. I have also spent some time to new macros related to continua of branches.)
documentclass{standalone}
usepackage{istgame}
begin{document}
begin{istgame}[scale=1.2,font=scriptsize]
% presets
tikzset{odd node/.style={decision node,minimum size=6pt}}
tikzset{even node/.style={oval node,fill=cyan!50,minimum size=6pt}}
NewDocumentCommandDASHEDcntm{ r() r() G{} O{below right} }
{
istroot(#1)(#2)[null node]+15mm..{(7/4)*15mm}+
istb[dashed] istb[dashed] endist
draw [dashed] (#1-1) -- (#1-2);
xtPayoff($(#1-1)!.5!(#1-2)$){#3}[#4]
}
% game tree
xtdistance{20mm}{35mm}
DASHEDcntm(1a)(0,0){(a^0,1-a^0)}
istroot(1a)[odd node]<15>{$x_1$} istb endist
istroot(2)(1a-1)[even node]<-90>{$x_2$}
istb{acc}[al]{left(a^0,1-a^0right)}
istb{not}[ar]
endist
DASHEDcntm(2a)(2-2){(a^1,1-a^1)}
istroot(2a)(2-2)[even node]<0>{$x_3$} istb endist
istroot(3)(2a-1)[odd node]<-90>{$x_4$}
istb{acc}[al]{left(delta_1 a^1,delta_2(1-a^1)right)}
istb{not}[ar]
endist
DASHEDcntm(3a)(3-2){(a^2,1-a^2)}
istroot(3a)(3-2)[odd node]<0>{$x_5$} istb endist
istroot(4)(3a-1)[even node]<-90>{$x_6$}
istb{acc}[al]{left((delta_1)^2a^2,(delta_2)^2(1-a^2)right)}
istb{not}[ar]{(0,0)}
endist
end{istgame}
end{document}
add a comment |
This is another example of using the istgame
package.
istgame version v2.0
With the version 2, you can use a new macro istroocntm, which is simpler (if used by defaults) and more powerful than using (obsolete) istcntm and istroot. You can control the features of a continuum triangle using cntmpreset(*).
documentclass{standalone}
usepackage{istgame}
begin{document}
begin{istgame}[font=scriptsize]
% presets
tikzset{odd node/.style={decision node,minimum size=6pt}}
tikzset{even node/.style={oval node,fill=cyan!50,minimum size=6pt}}
% game tree
cntmdistance*{20mm}{35mm}
cntmpreset*[densely dashed]{.6}
istrootcntm(1a)[odd node]<15>{$x_1$}
istb{(a^0,1-a^0)}[right,near end] endist
istroot(2)(1a-1)[even node]<-90>{$x_2$}
istb{acc}[al]{left(a^0,1-a^0right)}
istb{not}[ar]
endist
istrootcntm(2a)(2-2)[even node]<0>{$x_3$}
istb{(a^2,1-a^2)}[right,near end] endist
istroot(3)(2a-1)[odd node]<-90>{$x_4$}
istb{acc}[al]{left(delta_1 a^1,delta_2(1-a^1)right)}
istb{not}[ar]
endist
istrootcntm(3a)(3-2)[odd node]<0>{$x_5$}
istb{(a^2,1-a^2)}[right,near end] endist
istroot(4)(3a-1)[even node]<-90>{$x_6$}
istb{acc}[al]{left((delta_1)^2a^2,(delta_2)^2(1-a^2)right)}
istb{not}[ar]{(0,0)}
endist
end{istgame}
end{document}
original answer (istgame v1.0)
I borrowed distances and colors from Alan's answer, which will work in every direction of tree growing.
(I am working on an update for the istgame package, hoping that drawing game trees will be a little more easier in various situations. I have also spent some time to new macros related to continua of branches.)
documentclass{standalone}
usepackage{istgame}
begin{document}
begin{istgame}[scale=1.2,font=scriptsize]
% presets
tikzset{odd node/.style={decision node,minimum size=6pt}}
tikzset{even node/.style={oval node,fill=cyan!50,minimum size=6pt}}
NewDocumentCommandDASHEDcntm{ r() r() G{} O{below right} }
{
istroot(#1)(#2)[null node]+15mm..{(7/4)*15mm}+
istb[dashed] istb[dashed] endist
draw [dashed] (#1-1) -- (#1-2);
xtPayoff($(#1-1)!.5!(#1-2)$){#3}[#4]
}
% game tree
xtdistance{20mm}{35mm}
DASHEDcntm(1a)(0,0){(a^0,1-a^0)}
istroot(1a)[odd node]<15>{$x_1$} istb endist
istroot(2)(1a-1)[even node]<-90>{$x_2$}
istb{acc}[al]{left(a^0,1-a^0right)}
istb{not}[ar]
endist
DASHEDcntm(2a)(2-2){(a^1,1-a^1)}
istroot(2a)(2-2)[even node]<0>{$x_3$} istb endist
istroot(3)(2a-1)[odd node]<-90>{$x_4$}
istb{acc}[al]{left(delta_1 a^1,delta_2(1-a^1)right)}
istb{not}[ar]
endist
DASHEDcntm(3a)(3-2){(a^2,1-a^2)}
istroot(3a)(3-2)[odd node]<0>{$x_5$} istb endist
istroot(4)(3a-1)[even node]<-90>{$x_6$}
istb{acc}[al]{left((delta_1)^2a^2,(delta_2)^2(1-a^2)right)}
istb{not}[ar]{(0,0)}
endist
end{istgame}
end{document}
This is another example of using the istgame
package.
istgame version v2.0
With the version 2, you can use a new macro istroocntm, which is simpler (if used by defaults) and more powerful than using (obsolete) istcntm and istroot. You can control the features of a continuum triangle using cntmpreset(*).
documentclass{standalone}
usepackage{istgame}
begin{document}
begin{istgame}[font=scriptsize]
% presets
tikzset{odd node/.style={decision node,minimum size=6pt}}
tikzset{even node/.style={oval node,fill=cyan!50,minimum size=6pt}}
% game tree
cntmdistance*{20mm}{35mm}
cntmpreset*[densely dashed]{.6}
istrootcntm(1a)[odd node]<15>{$x_1$}
istb{(a^0,1-a^0)}[right,near end] endist
istroot(2)(1a-1)[even node]<-90>{$x_2$}
istb{acc}[al]{left(a^0,1-a^0right)}
istb{not}[ar]
endist
istrootcntm(2a)(2-2)[even node]<0>{$x_3$}
istb{(a^2,1-a^2)}[right,near end] endist
istroot(3)(2a-1)[odd node]<-90>{$x_4$}
istb{acc}[al]{left(delta_1 a^1,delta_2(1-a^1)right)}
istb{not}[ar]
endist
istrootcntm(3a)(3-2)[odd node]<0>{$x_5$}
istb{(a^2,1-a^2)}[right,near end] endist
istroot(4)(3a-1)[even node]<-90>{$x_6$}
istb{acc}[al]{left((delta_1)^2a^2,(delta_2)^2(1-a^2)right)}
istb{not}[ar]{(0,0)}
endist
end{istgame}
end{document}
original answer (istgame v1.0)
I borrowed distances and colors from Alan's answer, which will work in every direction of tree growing.
(I am working on an update for the istgame package, hoping that drawing game trees will be a little more easier in various situations. I have also spent some time to new macros related to continua of branches.)
documentclass{standalone}
usepackage{istgame}
begin{document}
begin{istgame}[scale=1.2,font=scriptsize]
% presets
tikzset{odd node/.style={decision node,minimum size=6pt}}
tikzset{even node/.style={oval node,fill=cyan!50,minimum size=6pt}}
NewDocumentCommandDASHEDcntm{ r() r() G{} O{below right} }
{
istroot(#1)(#2)[null node]+15mm..{(7/4)*15mm}+
istb[dashed] istb[dashed] endist
draw [dashed] (#1-1) -- (#1-2);
xtPayoff($(#1-1)!.5!(#1-2)$){#3}[#4]
}
% game tree
xtdistance{20mm}{35mm}
DASHEDcntm(1a)(0,0){(a^0,1-a^0)}
istroot(1a)[odd node]<15>{$x_1$} istb endist
istroot(2)(1a-1)[even node]<-90>{$x_2$}
istb{acc}[al]{left(a^0,1-a^0right)}
istb{not}[ar]
endist
DASHEDcntm(2a)(2-2){(a^1,1-a^1)}
istroot(2a)(2-2)[even node]<0>{$x_3$} istb endist
istroot(3)(2a-1)[odd node]<-90>{$x_4$}
istb{acc}[al]{left(delta_1 a^1,delta_2(1-a^1)right)}
istb{not}[ar]
endist
DASHEDcntm(3a)(3-2){(a^2,1-a^2)}
istroot(3a)(3-2)[odd node]<0>{$x_5$} istb endist
istroot(4)(3a-1)[even node]<-90>{$x_6$}
istb{acc}[al]{left((delta_1)^2a^2,(delta_2)^2(1-a^2)right)}
istb{not}[ar]{(0,0)}
endist
end{istgame}
end{document}
edited 15 mins ago
answered Jan 5 at 11:59
InSung ChoInSung Cho
86325
86325
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468397%2fdraw-tree-in-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
Please share your attempt with us as a MWE to help us help you.
– TeXnician
Jan 3 at 12:38
2
I would use the
istgame
package for drawing such trees. It's very well documented and is designed specifically for game trees.– Alan Munn
Jan 3 at 13:05