LaTeX forum ⇒ Graphics, Figures & TablesAdjust angle of a node with TikZ? Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
Legion9o
Posts: 1
Joined: Thu May 11, 2017 11:22 am

Adjust angle of a node with TikZ?

Postby Legion9o » Thu May 11, 2017 11:37 am

Hey!
I have a problem with a tree in TiKz.
The last branches of two nodes are crossing each other.
I tried it with adding the line \tikzstyle{level 3}=[sibling angle=30]but it doesnt work.
(The other angle lines are just to see if something happend ...).

How can I adjust the angles of the branches?

Heres my tree code:

  1. \tikzset{
  2. treenode/.style = {align=center, inner sep=0pt, text centered,
  3. font=\sffamily},
  4. arn_n/.style = {treenode, circle, white, font=\sffamily\bfseries, draw=black,
  5. fill=black, text width=1.5em},% arbre rouge noir, noeud noir
  6. arn_r/.style = {treenode, circle, black, draw=black,
  7. text width=1.5em, thin},% arbre rouge noir, noeud rouge
  8. arn_x/.style = {treenode, rectangle, draw=black,
  9. minimum width=0.5em, minimum height=0.5em}% arbre rouge noir, nil
  10. }
  11. \begin{center}
  12. \tikzstyle{level 1}=[sibling angle=120]
  13. \tikzstyle{level 2}=[sibling angle=60]
  14. \tikzstyle{level 3}=[sibling angle=30]
  15. \begin{tikzpicture}[->,>=stealth',level/.style={sibling distance = 7cm/#1,
  16. level distance = 1.5cm}]
  17. \node [arn_r] {$n$}
  18. child{ node [arn_r] {$\frac{2}{3}n$}
  19. child{ node [arn_r] {$\frac{4}{9}n$}
  20. child{ node [arn_r] {$\frac{8}{27}n$}
  21. child {node {$\vdots$}}
  22. child {node {$\vdots$}}}
  23. child{ node [arn_r] {$\frac{4}{27}n$}
  24. child {node {$\vdots$}}
  25. child {node {$\vdots$}}}
  26. }
  27. child{ node [arn_r] {$\frac{2}{9}n$}
  28. child{ node [arn_r] {$\frac{4}{27}n$}
  29. child {node {$\vdots$}}
  30. child {node {$\vdots$}}}
  31. child{ node [arn_r] {$\frac{2}{27}n$}
  32. child {node {$\vdots$}}
  33. child {node {$\vdots$}}}
  34. }
  35. }
  36. child{ node [arn_r] {$\frac{1}{3}n$}
  37. child{ node [arn_r] {$\frac{2}{9}n$}
  38. child {node {$\vdots$}}
  39. child {node {$\vdots$}}
  40. }
  41. child{ node [arn_r] {$\frac{1}{9}n$}
  42. child {node {$\vdots$}}
  43. child {node {$\vdots$}}
  44. }
  45. }
  46. ;
  47. \end{tikzpicture}
  48. \end{center}


Thanks for help

Tags:

User avatar
Stefan Kottwitz
Site Admin
Posts: 8522
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Wed May 17, 2017 3:45 pm

Hi,

welcome to the forum!

Legion9o wrote:How can I adjust the angles of the branches?


Instead of changing the angle, you could simply adjust the space between child nodes, such as by:

  1. \tikzset{
  2. level 0/.style = {sibling distance=6cm},
  3. level 1/.style = {sibling distance=9cm},
  4. level 2/.style = {sibling distance=5cm},
  5. }


Your tree then doesn't have overlapping edges:

tree.png
tree.png (15.5 KiB) Viewed 336 times


Stefan
Site admin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests