I'm drawing a horizontal tree with tikz-qtree. The edges to the leaf nodes are slanted, while I want them to be horizontal. I guess the problem is caused by the blank nodes before those leaf nodes. However, the edges will be perfectly vertical when the tree grows downward.
Code:
\documentclass{article}
\usepackage{tikz,tikz-qtree}
\usetikzlibrary{shapes,trees}
\begin{document}
\begin{tikzpicture}[
grow'=right,
level distance = 2cm,
level 2/.style={level distance=2cm,sibling distance=1cm},
frontier/.style={distance from root=10cm}
]
\Tree
[.\node[draw,rectangle,minimum size=0.8cm]{1};
\edge node[above,sloped]{\small Build A};
[.\node[draw,circle]{2};
\edge node[above,sloped]{\small Good(0.6)};
[.\node[draw,circle]{4};
[ \edge node[above]{\small Good(0.9)}; \node[rectangle]{\Large $\triangle$};]
[ \edge node[above]{\small Bad(0.1)}; \node[rectangle,inner sep=0pt]{\Large $\triangle$};]
]
\edge node[above,sloped]{\small Bad(0.4)};
[.\node[draw,circle]{5}; \edge node[above]{\small Bad(1)}; \node{\Large $\triangle$};]
]
\edge node[above,sloped]{\small Build B};
[.\node[draw,circle]{3};
\edge node[above,sloped]{\small Good(0.6)};
[.\node[rectangle,draw,minimum size=0.8cm]{6};
\edge node[above,sloped]{\small Expand};
[.\node[draw,circle]{8};
[ \edge node[above]{\small Good(0.9)}; \node[rectangle]{\Large $\triangle$};]
[ \edge node[above]{\small Bad(0.1)}; \node[rectangle]{\Large $\triangle$};]
]
\edge node[above,sloped]{\small No Expand};
[.\node[draw,circle]{9};
[ \edge node[above]{\small Good(0.9)}; \node[rectangle]{\Large $\triangle$};]
[ \edge node[above]{\small Bad(0.1)}; \node[rectangle]{\Large $\triangle$};]
]
]
\edge node[above,sloped]{\small Bad(0.4)};
[.\node[draw,circle]{7}; \edge node[above]{\small Bad(1)}; \node{\Large $\triangle$};]
]
]
\end{tikzpicture}
\end{document}




tikztree methods, and the question is usingtikz-qtree. – Alan Munn Jun 29 '20 at 15:30