Decision tree nodes overlapping with Tikz The 2019 Stack Overflow Developer Survey Results Are InLabeling precisely-positioned “tree” nodesTikz-Tree: Arrow-style depending on parent nodeHow to draw a tree with fixed node distances?Adjust edge endpoints depending on node labelHow can I draw a tree like in the image?Adding text above a node in Tikzpicture tree diagramHow to typeset a MinMax algorithm tree?forest: Draw a roof over multiple children in forest?Tikz mindmap customize nodes color, distance and sizeImproving a decision tree drawn with TikZ / forest
Why Did Howard Stark Use All The Vibranium They Had On A Prototype Shield?
Inflated grade on resume at previous job, might former employer tell new employer?
Landlord wants to switch my lease to a "Land contract" to "get back at the city"
What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?
Why do UK politicians seemingly ignore opinion polls on Brexit?
Extreme, unacceptable situation and I can't attend work tomorrow morning
It's possible to achieve negative score?
Does it makes sense to buy a new cycle to learn riding?
Where does the "burst of radiance" from Holy Weapon originate?
aging parents with no investments
Does a dangling wire really electrocute me if I'm standing in water?
I see my dog run
Idiomatic way to prevent slicing?
If a poisoned arrow's piercing damage is reduced to 0, do you still get poisoned?
Manuscript was "unsubmitted" because the manuscript was deposited in Arxiv Preprints
Why don't Unix/Linux systems traverse through directories until they find the required version of a linked library?
JSON.serialize: is it possible to suppress null values of a map?
Why can Shazam do this?
How to deal with fear of taking dependencies
Monty Hall variation
Where to refill my bottle in India?
Is bread bad for ducks?
What is the best strategy for white in this position?
What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?
Decision tree nodes overlapping with Tikz
The 2019 Stack Overflow Developer Survey Results Are InLabeling precisely-positioned “tree” nodesTikz-Tree: Arrow-style depending on parent nodeHow to draw a tree with fixed node distances?Adjust edge endpoints depending on node labelHow can I draw a tree like in the image?Adding text above a node in Tikzpicture tree diagramHow to typeset a MinMax algorithm tree?forest: Draw a roof over multiple children in forest?Tikz mindmap customize nodes color, distance and sizeImproving a decision tree drawn with TikZ / forest
Does anyone know how to prevent the branches of a decision tree from converging on each other? This is with Tikz - I've tried tweaking the sibling distance and things like that, but two of the branches at the end converge so that the final values are illegible.
Secondly, does anyone know how to put in a dashed line between the two square "choice" siblings? To indicate an information set.
documentclassarticle
usepackagetikz
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black, font=normalsize,
chance/.style = shape=circle, draw, align=center, color=black, fill=black, font=normalsize,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
beginfigure[H]
centering
begintikzpicture
[
grow = right,
sibling distance = 6em,
level distance = 8em,
edge from parent/.style = draw, -latex,
every node/.style = font=normalsize,
sloped
]
node [root]
child node [outcome, label=right:$30]
edge from parent node [below]
child node [choice]
child node [chance]
child node [choice]
child node [outcome, label=right:$10]
child node[outcome, label=right:$100]
edge from parent node [below] .5
child node [choice]
child node [outcome, label=right:$45]
child node [outcome, label=right:$55]
edge from parent node [above] .5
edge from parent node [below]
child node [outcome, label=right:$25]
edge from parent node [above]
edge from parent node [above] ;
endtikzpicture
captionSample Decision Tree labelfig: Sample
endfigure
tikz-pgf tikz-trees trees
New contributor
add a comment |
Does anyone know how to prevent the branches of a decision tree from converging on each other? This is with Tikz - I've tried tweaking the sibling distance and things like that, but two of the branches at the end converge so that the final values are illegible.
Secondly, does anyone know how to put in a dashed line between the two square "choice" siblings? To indicate an information set.
documentclassarticle
usepackagetikz
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black, font=normalsize,
chance/.style = shape=circle, draw, align=center, color=black, fill=black, font=normalsize,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
beginfigure[H]
centering
begintikzpicture
[
grow = right,
sibling distance = 6em,
level distance = 8em,
edge from parent/.style = draw, -latex,
every node/.style = font=normalsize,
sloped
]
node [root]
child node [outcome, label=right:$30]
edge from parent node [below]
child node [choice]
child node [chance]
child node [choice]
child node [outcome, label=right:$10]
child node[outcome, label=right:$100]
edge from parent node [below] .5
child node [choice]
child node [outcome, label=right:$45]
child node [outcome, label=right:$55]
edge from parent node [above] .5
edge from parent node [below]
child node [outcome, label=right:$25]
edge from parent node [above]
edge from parent node [above] ;
endtikzpicture
captionSample Decision Tree labelfig: Sample
endfigure
tikz-pgf tikz-trees trees
New contributor
add a comment |
Does anyone know how to prevent the branches of a decision tree from converging on each other? This is with Tikz - I've tried tweaking the sibling distance and things like that, but two of the branches at the end converge so that the final values are illegible.
Secondly, does anyone know how to put in a dashed line between the two square "choice" siblings? To indicate an information set.
documentclassarticle
usepackagetikz
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black, font=normalsize,
chance/.style = shape=circle, draw, align=center, color=black, fill=black, font=normalsize,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
beginfigure[H]
centering
begintikzpicture
[
grow = right,
sibling distance = 6em,
level distance = 8em,
edge from parent/.style = draw, -latex,
every node/.style = font=normalsize,
sloped
]
node [root]
child node [outcome, label=right:$30]
edge from parent node [below]
child node [choice]
child node [chance]
child node [choice]
child node [outcome, label=right:$10]
child node[outcome, label=right:$100]
edge from parent node [below] .5
child node [choice]
child node [outcome, label=right:$45]
child node [outcome, label=right:$55]
edge from parent node [above] .5
edge from parent node [below]
child node [outcome, label=right:$25]
edge from parent node [above]
edge from parent node [above] ;
endtikzpicture
captionSample Decision Tree labelfig: Sample
endfigure
tikz-pgf tikz-trees trees
New contributor
Does anyone know how to prevent the branches of a decision tree from converging on each other? This is with Tikz - I've tried tweaking the sibling distance and things like that, but two of the branches at the end converge so that the final values are illegible.
Secondly, does anyone know how to put in a dashed line between the two square "choice" siblings? To indicate an information set.
documentclassarticle
usepackagetikz
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black, font=normalsize,
chance/.style = shape=circle, draw, align=center, color=black, fill=black, font=normalsize,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
beginfigure[H]
centering
begintikzpicture
[
grow = right,
sibling distance = 6em,
level distance = 8em,
edge from parent/.style = draw, -latex,
every node/.style = font=normalsize,
sloped
]
node [root]
child node [outcome, label=right:$30]
edge from parent node [below]
child node [choice]
child node [chance]
child node [choice]
child node [outcome, label=right:$10]
child node[outcome, label=right:$100]
edge from parent node [below] .5
child node [choice]
child node [outcome, label=right:$45]
child node [outcome, label=right:$55]
edge from parent node [above] .5
edge from parent node [below]
child node [outcome, label=right:$25]
edge from parent node [above]
edge from parent node [above] ;
endtikzpicture
captionSample Decision Tree labelfig: Sample
endfigure
tikz-pgf tikz-trees trees
tikz-pgf tikz-trees trees
New contributor
New contributor
New contributor
asked Apr 5 at 15:06
user185143user185143
332
332
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I use yshift
option to change the position of the nodes, to avoid overlapping.
I give two choice
nodes some names (a
and b
) and draw a dashed line as usual.
Code:
documentclass[tikz]standalone
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black, font=normalsize,
chance/.style = shape=circle, draw, align=center, color=black, fill=black, font=normalsize,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
begindocument
begintikzpicture
[
grow = right,
sibling distance = 6em,
level distance = 8em,
edge from parent/.style = draw, -latex,
every node/.style = font=normalsize,
sloped
]
node [root]
child node [outcome, label=right:$30]
edge from parent node [below]
child node [choice]
child node [chance]
child node [choice] (a)
child node [outcome, label=right:$10]
child node[yshift=-2em,outcome, label=right:$100]
edge from parent node [below] .5
child node [choice] (b)
child node [yshift=2em,outcome, label=right:$45]
child node [outcome, label=right:$55]
edge from parent node [above] .5
edge from parent node [below]
child node [outcome, label=right:$25]
edge from parent node [above]
edge from parent node [above] ;
draw[dashed] (a)--(b);
endtikzpicture
enddocument
add a comment |
I would like to recommend forest, where the syntax is simpler and you do not have to worry about these things.
documentclassarticle
usepackage[edges]forest
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black,
chance/.style = shape=circle, draw, align=center, color=black, fill=black,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
begindocument
beginforest
for tree=grow'=east,edge=-latex,l+=1cm
[,root
[,choice
[$25]
[,chance
[,choice,edge label=node[midway,above,sloped].5
[$55]
[$45]
]
[,choice,edge label=node[midway,below,sloped].5
[$100]
[$10]
]
]
]
[$30]
]
endforest
enddocument
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
);
);
user185143 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f483367%2fdecision-tree-nodes-overlapping-with-tikz%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I use yshift
option to change the position of the nodes, to avoid overlapping.
I give two choice
nodes some names (a
and b
) and draw a dashed line as usual.
Code:
documentclass[tikz]standalone
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black, font=normalsize,
chance/.style = shape=circle, draw, align=center, color=black, fill=black, font=normalsize,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
begindocument
begintikzpicture
[
grow = right,
sibling distance = 6em,
level distance = 8em,
edge from parent/.style = draw, -latex,
every node/.style = font=normalsize,
sloped
]
node [root]
child node [outcome, label=right:$30]
edge from parent node [below]
child node [choice]
child node [chance]
child node [choice] (a)
child node [outcome, label=right:$10]
child node[yshift=-2em,outcome, label=right:$100]
edge from parent node [below] .5
child node [choice] (b)
child node [yshift=2em,outcome, label=right:$45]
child node [outcome, label=right:$55]
edge from parent node [above] .5
edge from parent node [below]
child node [outcome, label=right:$25]
edge from parent node [above]
edge from parent node [above] ;
draw[dashed] (a)--(b);
endtikzpicture
enddocument
add a comment |
I use yshift
option to change the position of the nodes, to avoid overlapping.
I give two choice
nodes some names (a
and b
) and draw a dashed line as usual.
Code:
documentclass[tikz]standalone
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black, font=normalsize,
chance/.style = shape=circle, draw, align=center, color=black, fill=black, font=normalsize,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
begindocument
begintikzpicture
[
grow = right,
sibling distance = 6em,
level distance = 8em,
edge from parent/.style = draw, -latex,
every node/.style = font=normalsize,
sloped
]
node [root]
child node [outcome, label=right:$30]
edge from parent node [below]
child node [choice]
child node [chance]
child node [choice] (a)
child node [outcome, label=right:$10]
child node[yshift=-2em,outcome, label=right:$100]
edge from parent node [below] .5
child node [choice] (b)
child node [yshift=2em,outcome, label=right:$45]
child node [outcome, label=right:$55]
edge from parent node [above] .5
edge from parent node [below]
child node [outcome, label=right:$25]
edge from parent node [above]
edge from parent node [above] ;
draw[dashed] (a)--(b);
endtikzpicture
enddocument
add a comment |
I use yshift
option to change the position of the nodes, to avoid overlapping.
I give two choice
nodes some names (a
and b
) and draw a dashed line as usual.
Code:
documentclass[tikz]standalone
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black, font=normalsize,
chance/.style = shape=circle, draw, align=center, color=black, fill=black, font=normalsize,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
begindocument
begintikzpicture
[
grow = right,
sibling distance = 6em,
level distance = 8em,
edge from parent/.style = draw, -latex,
every node/.style = font=normalsize,
sloped
]
node [root]
child node [outcome, label=right:$30]
edge from parent node [below]
child node [choice]
child node [chance]
child node [choice] (a)
child node [outcome, label=right:$10]
child node[yshift=-2em,outcome, label=right:$100]
edge from parent node [below] .5
child node [choice] (b)
child node [yshift=2em,outcome, label=right:$45]
child node [outcome, label=right:$55]
edge from parent node [above] .5
edge from parent node [below]
child node [outcome, label=right:$25]
edge from parent node [above]
edge from parent node [above] ;
draw[dashed] (a)--(b);
endtikzpicture
enddocument
I use yshift
option to change the position of the nodes, to avoid overlapping.
I give two choice
nodes some names (a
and b
) and draw a dashed line as usual.
Code:
documentclass[tikz]standalone
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black, font=normalsize,
chance/.style = shape=circle, draw, align=center, color=black, fill=black, font=normalsize,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
begindocument
begintikzpicture
[
grow = right,
sibling distance = 6em,
level distance = 8em,
edge from parent/.style = draw, -latex,
every node/.style = font=normalsize,
sloped
]
node [root]
child node [outcome, label=right:$30]
edge from parent node [below]
child node [choice]
child node [chance]
child node [choice] (a)
child node [outcome, label=right:$10]
child node[yshift=-2em,outcome, label=right:$100]
edge from parent node [below] .5
child node [choice] (b)
child node [yshift=2em,outcome, label=right:$45]
child node [outcome, label=right:$55]
edge from parent node [above] .5
edge from parent node [below]
child node [outcome, label=right:$25]
edge from parent node [above]
edge from parent node [above] ;
draw[dashed] (a)--(b);
endtikzpicture
enddocument
answered Apr 5 at 15:11
JouleVJouleV
12k22662
12k22662
add a comment |
add a comment |
I would like to recommend forest, where the syntax is simpler and you do not have to worry about these things.
documentclassarticle
usepackage[edges]forest
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black,
chance/.style = shape=circle, draw, align=center, color=black, fill=black,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
begindocument
beginforest
for tree=grow'=east,edge=-latex,l+=1cm
[,root
[,choice
[$25]
[,chance
[,choice,edge label=node[midway,above,sloped].5
[$55]
[$45]
]
[,choice,edge label=node[midway,below,sloped].5
[$100]
[$10]
]
]
]
[$30]
]
endforest
enddocument
add a comment |
I would like to recommend forest, where the syntax is simpler and you do not have to worry about these things.
documentclassarticle
usepackage[edges]forest
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black,
chance/.style = shape=circle, draw, align=center, color=black, fill=black,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
begindocument
beginforest
for tree=grow'=east,edge=-latex,l+=1cm
[,root
[,choice
[$25]
[,chance
[,choice,edge label=node[midway,above,sloped].5
[$55]
[$45]
]
[,choice,edge label=node[midway,below,sloped].5
[$100]
[$10]
]
]
]
[$30]
]
endforest
enddocument
add a comment |
I would like to recommend forest, where the syntax is simpler and you do not have to worry about these things.
documentclassarticle
usepackage[edges]forest
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black,
chance/.style = shape=circle, draw, align=center, color=black, fill=black,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
begindocument
beginforest
for tree=grow'=east,edge=-latex,l+=1cm
[,root
[,choice
[$25]
[,chance
[,choice,edge label=node[midway,above,sloped].5
[$55]
[$45]
]
[,choice,edge label=node[midway,below,sloped].5
[$100]
[$10]
]
]
]
[$30]
]
endforest
enddocument
I would like to recommend forest, where the syntax is simpler and you do not have to worry about these things.
documentclassarticle
usepackage[edges]forest
tikzset
choice/.style = shape=rectangle, draw, align=center, color=black, fill=black,
chance/.style = shape=circle, draw, align=center, color=black, fill=black,
root/.style = choice, font=normalsize, color=black,
outcome/.style = shape=rectangle, draw=white, align=center, font=tiny, parent anchor=left,
begindocument
beginforest
for tree=grow'=east,edge=-latex,l+=1cm
[,root
[,choice
[$25]
[,chance
[,choice,edge label=node[midway,above,sloped].5
[$55]
[$45]
]
[,choice,edge label=node[midway,below,sloped].5
[$100]
[$10]
]
]
]
[$30]
]
endforest
enddocument
answered Apr 5 at 15:22
marmotmarmot
116k5149280
116k5149280
add a comment |
add a comment |
user185143 is a new contributor. Be nice, and check out our Code of Conduct.
user185143 is a new contributor. Be nice, and check out our Code of Conduct.
user185143 is a new contributor. Be nice, and check out our Code of Conduct.
user185143 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f483367%2fdecision-tree-nodes-overlapping-with-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