Making tree structure using tikz
I want to make a tree structure by tikz
. I am not a professional latex user and I am just trying to combine examples to make it work but first I would like that the edges have direction and then T 3
and T 4
overlap and then I would like to be able to make the space between nodes in each layer being more flexible to change. This in my code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}
end{document}
There is a circle created on the edges between char 1
and script 1
. I can not figure why? Any suggestion would be appreciate!!
tikz-pgf tikz-trees graphs
add a comment |
I want to make a tree structure by tikz
. I am not a professional latex user and I am just trying to combine examples to make it work but first I would like that the edges have direction and then T 3
and T 4
overlap and then I would like to be able to make the space between nodes in each layer being more flexible to change. This in my code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}
end{document}
There is a circle created on the edges between char 1
and script 1
. I can not figure why? Any suggestion would be appreciate!!
tikz-pgf tikz-trees graphs
Also, there are many packages, which allow you to construct trees which are easier to use.
– Viktor Glombik
4 hours ago
@ViktorGlombik If you are referring toforest
, I agree, but giving a list of packages you have in mind might help here.
– marmot
3 hours ago
add a comment |
I want to make a tree structure by tikz
. I am not a professional latex user and I am just trying to combine examples to make it work but first I would like that the edges have direction and then T 3
and T 4
overlap and then I would like to be able to make the space between nodes in each layer being more flexible to change. This in my code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}
end{document}
There is a circle created on the edges between char 1
and script 1
. I can not figure why? Any suggestion would be appreciate!!
tikz-pgf tikz-trees graphs
I want to make a tree structure by tikz
. I am not a professional latex user and I am just trying to combine examples to make it work but first I would like that the edges have direction and then T 3
and T 4
overlap and then I would like to be able to make the space between nodes in each layer being more flexible to change. This in my code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}
end{document}
There is a circle created on the edges between char 1
and script 1
. I can not figure why? Any suggestion would be appreciate!!
tikz-pgf tikz-trees graphs
tikz-pgf tikz-trees graphs
asked 5 hours ago
DalekDalek
21917
21917
Also, there are many packages, which allow you to construct trees which are easier to use.
– Viktor Glombik
4 hours ago
@ViktorGlombik If you are referring toforest
, I agree, but giving a list of packages you have in mind might help here.
– marmot
3 hours ago
add a comment |
Also, there are many packages, which allow you to construct trees which are easier to use.
– Viktor Glombik
4 hours ago
@ViktorGlombik If you are referring toforest
, I agree, but giving a list of packages you have in mind might help here.
– marmot
3 hours ago
Also, there are many packages, which allow you to construct trees which are easier to use.
– Viktor Glombik
4 hours ago
Also, there are many packages, which allow you to construct trees which are easier to use.
– Viktor Glombik
4 hours ago
@ViktorGlombik If you are referring to
forest
, I agree, but giving a list of packages you have in mind might help here.– marmot
3 hours ago
@ViktorGlombik If you are referring to
forest
, I agree, but giving a list of packages you have in mind might help here.– marmot
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
- The circles appear because you have
node{}
inpath [line] (s2) -- node {}(ch2);
- You can add arrows by saying
edge from parent/.style={draw,-latex'}
. - You were loading
graphdrawing
but it is not obvious to me you were using it.
left=2cm of char 1
should probably beleft=2cm of ch1
.- You can change the dimensions/distances at any level using e.g.
level 1/.style={sibling distance=50mm},level 2/.style={sibling distance=15mm},level 3/.style={text width=1cm,font=tiny}
. - To debug you may temporarily set
opacity=0.5
to better understand where some nodes went. - The rest of your statements I do not understand. Could you perhaps consider making them clearer?
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=50mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}
documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}
end{document}
I am confused by your comments. Something like this?
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=30mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 3}
child { node {comment} } }
child { node {T 2}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}
Note that this is just to clarify your request, and not a proposal for really do this. (And this is not a tree.)
Thanks for the answer but I still do not see the leave corresponding toT 3
. where is it?
– Dalek
4 hours ago
@Dalek It is where you put it: underT4
. You can check this by addingopacity=0.5
to the options ofbegin{tikzpicture}
. May I ask where you want to have it?
– marmot
4 hours ago
but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?
– Dalek
4 hours ago
@Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)
– marmot
4 hours ago
@mamot Thanks. Is it possible in the case of shared lower level node, both the higher levelchar1
andchar2
be connected to the same node for instance,T2
instead of having two nodes?
– Dalek
3 hours ago
|
show 4 more comments
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%2f473550%2fmaking-tree-structure-using-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
- The circles appear because you have
node{}
inpath [line] (s2) -- node {}(ch2);
- You can add arrows by saying
edge from parent/.style={draw,-latex'}
. - You were loading
graphdrawing
but it is not obvious to me you were using it.
left=2cm of char 1
should probably beleft=2cm of ch1
.- You can change the dimensions/distances at any level using e.g.
level 1/.style={sibling distance=50mm},level 2/.style={sibling distance=15mm},level 3/.style={text width=1cm,font=tiny}
. - To debug you may temporarily set
opacity=0.5
to better understand where some nodes went. - The rest of your statements I do not understand. Could you perhaps consider making them clearer?
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=50mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}
documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}
end{document}
I am confused by your comments. Something like this?
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=30mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 3}
child { node {comment} } }
child { node {T 2}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}
Note that this is just to clarify your request, and not a proposal for really do this. (And this is not a tree.)
Thanks for the answer but I still do not see the leave corresponding toT 3
. where is it?
– Dalek
4 hours ago
@Dalek It is where you put it: underT4
. You can check this by addingopacity=0.5
to the options ofbegin{tikzpicture}
. May I ask where you want to have it?
– marmot
4 hours ago
but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?
– Dalek
4 hours ago
@Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)
– marmot
4 hours ago
@mamot Thanks. Is it possible in the case of shared lower level node, both the higher levelchar1
andchar2
be connected to the same node for instance,T2
instead of having two nodes?
– Dalek
3 hours ago
|
show 4 more comments
- The circles appear because you have
node{}
inpath [line] (s2) -- node {}(ch2);
- You can add arrows by saying
edge from parent/.style={draw,-latex'}
. - You were loading
graphdrawing
but it is not obvious to me you were using it.
left=2cm of char 1
should probably beleft=2cm of ch1
.- You can change the dimensions/distances at any level using e.g.
level 1/.style={sibling distance=50mm},level 2/.style={sibling distance=15mm},level 3/.style={text width=1cm,font=tiny}
. - To debug you may temporarily set
opacity=0.5
to better understand where some nodes went. - The rest of your statements I do not understand. Could you perhaps consider making them clearer?
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=50mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}
documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}
end{document}
I am confused by your comments. Something like this?
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=30mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 3}
child { node {comment} } }
child { node {T 2}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}
Note that this is just to clarify your request, and not a proposal for really do this. (And this is not a tree.)
Thanks for the answer but I still do not see the leave corresponding toT 3
. where is it?
– Dalek
4 hours ago
@Dalek It is where you put it: underT4
. You can check this by addingopacity=0.5
to the options ofbegin{tikzpicture}
. May I ask where you want to have it?
– marmot
4 hours ago
but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?
– Dalek
4 hours ago
@Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)
– marmot
4 hours ago
@mamot Thanks. Is it possible in the case of shared lower level node, both the higher levelchar1
andchar2
be connected to the same node for instance,T2
instead of having two nodes?
– Dalek
3 hours ago
|
show 4 more comments
- The circles appear because you have
node{}
inpath [line] (s2) -- node {}(ch2);
- You can add arrows by saying
edge from parent/.style={draw,-latex'}
. - You were loading
graphdrawing
but it is not obvious to me you were using it.
left=2cm of char 1
should probably beleft=2cm of ch1
.- You can change the dimensions/distances at any level using e.g.
level 1/.style={sibling distance=50mm},level 2/.style={sibling distance=15mm},level 3/.style={text width=1cm,font=tiny}
. - To debug you may temporarily set
opacity=0.5
to better understand where some nodes went. - The rest of your statements I do not understand. Could you perhaps consider making them clearer?
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=50mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}
documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}
end{document}
I am confused by your comments. Something like this?
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=30mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 3}
child { node {comment} } }
child { node {T 2}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}
Note that this is just to clarify your request, and not a proposal for really do this. (And this is not a tree.)
- The circles appear because you have
node{}
inpath [line] (s2) -- node {}(ch2);
- You can add arrows by saying
edge from parent/.style={draw,-latex'}
. - You were loading
graphdrawing
but it is not obvious to me you were using it.
left=2cm of char 1
should probably beleft=2cm of ch1
.- You can change the dimensions/distances at any level using e.g.
level 1/.style={sibling distance=50mm},level 2/.style={sibling distance=15mm},level 3/.style={text width=1cm,font=tiny}
. - To debug you may temporarily set
opacity=0.5
to better understand where some nodes went. - The rest of your statements I do not understand. Could you perhaps consider making them clearer?
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=50mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}
documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}
end{document}
I am confused by your comments. Something like this?
documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=30mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 3}
child { node {comment} } }
child { node {T 2}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}
Note that this is just to clarify your request, and not a proposal for really do this. (And this is not a tree.)
edited 3 hours ago
answered 4 hours ago
marmotmarmot
97.6k4112215
97.6k4112215
Thanks for the answer but I still do not see the leave corresponding toT 3
. where is it?
– Dalek
4 hours ago
@Dalek It is where you put it: underT4
. You can check this by addingopacity=0.5
to the options ofbegin{tikzpicture}
. May I ask where you want to have it?
– marmot
4 hours ago
but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?
– Dalek
4 hours ago
@Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)
– marmot
4 hours ago
@mamot Thanks. Is it possible in the case of shared lower level node, both the higher levelchar1
andchar2
be connected to the same node for instance,T2
instead of having two nodes?
– Dalek
3 hours ago
|
show 4 more comments
Thanks for the answer but I still do not see the leave corresponding toT 3
. where is it?
– Dalek
4 hours ago
@Dalek It is where you put it: underT4
. You can check this by addingopacity=0.5
to the options ofbegin{tikzpicture}
. May I ask where you want to have it?
– marmot
4 hours ago
but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?
– Dalek
4 hours ago
@Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)
– marmot
4 hours ago
@mamot Thanks. Is it possible in the case of shared lower level node, both the higher levelchar1
andchar2
be connected to the same node for instance,T2
instead of having two nodes?
– Dalek
3 hours ago
Thanks for the answer but I still do not see the leave corresponding to
T 3
. where is it?– Dalek
4 hours ago
Thanks for the answer but I still do not see the leave corresponding to
T 3
. where is it?– Dalek
4 hours ago
@Dalek It is where you put it: under
T4
. You can check this by adding opacity=0.5
to the options of begin{tikzpicture}
. May I ask where you want to have it?– marmot
4 hours ago
@Dalek It is where you put it: under
T4
. You can check this by adding opacity=0.5
to the options of begin{tikzpicture}
. May I ask where you want to have it?– marmot
4 hours ago
but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?
– Dalek
4 hours ago
but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?
– Dalek
4 hours ago
@Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)
– marmot
4 hours ago
@Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)
– marmot
4 hours ago
@mamot Thanks. Is it possible in the case of shared lower level node, both the higher level
char1
and char2
be connected to the same node for instance, T2
instead of having two nodes?– Dalek
3 hours ago
@mamot Thanks. Is it possible in the case of shared lower level node, both the higher level
char1
and char2
be connected to the same node for instance, T2
instead of having two nodes?– Dalek
3 hours ago
|
show 4 more comments
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%2f473550%2fmaking-tree-structure-using-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
Also, there are many packages, which allow you to construct trees which are easier to use.
– Viktor Glombik
4 hours ago
@ViktorGlombik If you are referring to
forest
, I agree, but giving a list of packages you have in mind might help here.– marmot
3 hours ago