我有下面的代码来生成基本的概率树。
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
grow=right,
level distance=3cm,
level 1/.style = {sibling distance=12em},
level 2/.style = {sibling distance=8em},
%
every node/.style = {rounded corners,
draw, align=center,
top color=white, bottom color=white}
]
\node {}
child { node {$T_3$}
edge from parent node[above] { $\frac{1}{1+l}$ }}
child { node {$T_2$}
edge from parent node[above] { $\frac{1}{1+l}$ }}
child { node {$\vdots$}}
child { node {$T_1$}
edge from parent node[above] { $\frac{1}{1+l}$ }}
child { node {$T_0$}
edge from parent node[above] { $\frac{1}{1+l}$ } };
\end{tikzpicture}
\end{document}
我怎样才能删除它,而不是使用标准的线和框\vdots
,使它们\vdots
成为独立的(意味着图中存在多个“隐藏”分支)?
答案1
感谢@Qrrbrbirbel 指出他的评论感谢 @cfr 完成您的代码片段,以下是为您阐述的方法。相关代码行如下:
child { node[draw=none,minimum width=3em] {$\vdots$}}% <<<
draw=none
根本没有画出节点的形状minimum width=3em
可能有助于加宽节点文本字段,将点稍微向右移动(1em 是单个m
字符的宽度;您也可以使用 mm、pt、cm、in 等)
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
grow=right,
level distance=3cm,
level 1/.style = {sibling distance=12em},
level 2/.style = {sibling distance=8em},
%
every node/.style = {rounded corners,
draw, align=center,
top color=white, bottom color=white}
]
\node {}
child { node {$T_3$}
edge from parent node[above] { $\frac{1}{1+l}$ }}
child { node {$T_2$}
edge from parent node[above] { $\frac{1}{1+l}$ }}
child { node[draw=none,minimum width=3em] {$\vdots$}}% <<<
child { node {$T_1$}
edge from parent node[above] { $\frac{1}{1+l}$ }}
child { node {$T_0$}
edge from parent node[above] { $\frac{1}{1+l}$ } };
\end{tikzpicture}
\end{document}
跟进评论:要修改碱液,请修改child
的选项,如下所示:
child[dotted, red] { node[draw=none,minimum width=3em,black] {$\vdots$}}% <<<
如果您希望两者都为红色,请执行以下操作:
child[dotted, red] { node[draw=none,minimum width=3em] {$\vdots$}}% <<<