1

How can I make the following decision tree legible?

enter image description here

The code is below:

\begin{forest}
for tree={l sep+=.8cm,s sep+=.5cm,shape=rectangle, rounded corners,
    draw, align=center,
    top color=white, bottom color=gray!20}
[Root,edge label={node[midway,left]{z=0}} 
  [Unacceptable,edge label={node[midway,left]{Safety=Low}}   
  ]
    [Split on Doors,edge label={node[midway,left]{Safety=Medium}} 
    [Unacceptable,for children={font=\bfseries},edge label=
    {node[midway,left]{Doors=2}} ]
    [Acceptable,for children={font=\bfseries},edge label=
    {node[midway,left]{Doors=3}} ]   
    [Good,for children={font=\bfseries},edge label={node[midway,left]
    {Doors=4}} ]  
    [Split on Lugboot,for children={font=\bfseries},edge label=
    {node[midway,left]{Doors=5more}}
      [Acceptable,for children={font=\bfseries},edge label=
      {node[midway,left]{Lugboot=Small}} ]  
      [Good,for children={font=\bfseries},edge label={node[midway,left]
      {Lugboot=Medium}} ]  
      [Good,for children={font=\bfseries},edge label={node[midway,left]
      {Lugboot=Big}} ]  
   ]   
 ]  
 [Split on lugboot,edge label={node[midway,left]{Safety=High}} 
 [Split on Persons,for children={font=\bfseries},edge label={node[midway,left]{Small}} 
   [Unacceptable,edge label={node[midway,left]{Persons=2}}   
   ]    
   [Good,edge label={node[midway,left]{Persons=4}}   
   ]    
   [Good,edge label={node[midway,left]{Persons=5more}}   
   ]    
 ]  
 [Vgood,for children={font=\bfseries},edge label={node[midway,left]{Medium}} ]    
 [Vgood,for children={font=\bfseries},edge label={node[midway,left]
 {Big}} ] 
]  
]    
\end{forest}
  • A mock up of the desired results might help. – A Feldman Nov 17 '17 at 10:59
  • Appropriate tags would have likely yielded at least one solution by now, though a proper MWE would help. – cfr Dec 18 '17 at 0:53
  • If part of the question is supposed to concern fitting the tree to the page, this can't be meaningfully answered without a proper MWE as it can't be known what the dimensions of the page are. US letter/ A4? Beamer-slide-size? A3? A5? How big are the margins? What's the default orientation? – cfr Dec 18 '17 at 1:32
  • The labels can be sorted out, however, if somebody knows how to complete the example. However, even this isn't guaranteed without a more complete context. – cfr Dec 18 '17 at 1:33
1

It isn't clear what your constraints are, but the following is certainly legible.

legible version of tree

\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}

\begin{document}
\begin{forest}
  for tree={
    l sep'+=.8cm,
    s sep'+=.5cm,
    rounded corners,
    draw, 
    align=center,
    top color=white, 
    bottom color=gray!20,
  },
  forked edges,
  my label/.style={
    edge label={
      node [midway, below right, align=center] {#1}
    },
  }
  [Root,edge label={node[midway,left]{z=0}} 
    [Unacceptable, my label={Safety=Low} 
    ]
    [Split on Doors, my label={Safety=Medium} 
      [Unacceptable,for children={font=\bfseries}, my label={Doors=2}
      ]
      [Acceptable,for children={font=\bfseries}, my label={Doors=3}
      ]   
      [Good,for children={font=\bfseries}, my label={Doors=4}
      ]  
      [Split on Lugboot,for children={font=\bfseries}, my label={Doors=5more}
        [Acceptable,for children={font=\bfseries}, my label={Lugboot\\=Small} ]  
        [Good,for children={font=\bfseries}, my label={Lugboot\\=Medium} ]  
        [Good,for children={font=\bfseries}, my label={Lugboot\\=Big} ]  
      ]   
    ]  
    [Split on lugboot, my label={Safety=High} 
      [Split on Persons,for children={font=\bfseries}, my label={Small} 
        [Unacceptable, my label={Persons=2}   
        ]    
        [Good, my label={Persons=4}   
        ]    
        [Good, my label={Persons=5more}   
        ]    
      ]  
      [Vgood,for children={font=\bfseries}, my label={Medium} ]    
      [Vgood,for children={font=\bfseries}, my label={Big} ] 
    ]  
  ]    
\end{forest}
\end{document}

Your Answer

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

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