答案1
\documentclass[tikz,border=10pt]{standalone}
\usepackage{forest}
\usetikzlibrary{shadows}
\tikzset{every shadow/.style={shadow xshift=5pt,shadow yshift=-5pt}}
\begin{document}
% starting point: https://tex.stackexchange.com/a/341454/121799
\begin{forest}
for tree={
font=\sffamily,
line width=1pt,
draw,
child anchor=north,
parent anchor=south,
grow=south,
align=center,
edge path={
\noexpand\path[line width=1pt, \forestoption{edge}]
(!u.parent anchor) |- ([yshift=4pt].child anchor) -- (.child anchor) \forestoption{edge label};
},
},
s sep+=20pt,
[1 Clustering Ensemble\\ Approaches,drop shadow,
fill=white,double=white,
[2.1 Generative\\ Mechanism,double=white
[3.1 Different\\ Algorithms]
[,phantom]
[3.2 Single\\ Algorithms
[4.1 Different built--in\\ initialization]
[~\\~,opacity=0,name=phantom1
[4.3 Different subsets\\ of features]
[~\\~,opacity=0,name=phantom2
[4.5 Different subsets\\ of objects]
]
[4.4 Projecting data\\ onto different subspaces]
]
[4.2 Different\\ parameters]
]
]
[2.2 Consensus\\ Function,double=white
[3.3 Information Theory\\ Approach]
[~\\~,opacity=0,name=phantom3
[3.5 Voting approach]
[~,opacity=0,name=phantom4
[3.7 Hypergraph\\ methods]
]
[3.6 Mixture Model (EM)]
]
[3.4 Co--association\\ based approach]
]
]
\begin{scope}[line width=1pt]
\foreach \X in {1,...,4}
{\draw (phantom\X.north) -- (phantom\X.south);}
\end{scope}
\end{forest}
\end{document}
答案2
这是使用 Forest 库的版本edges
,它使这些类型的树变得容易得多。我厚颜无耻地偷了土拨鼠密码以避免全部输入,但我稍微改变了树的结构以简化事情,并依赖于 Forest 选项而不是手动间距,以帮助确保一致性并使代码更简单、更灵活。
我还对样式进行了调整,因为完成后我不喜欢双线或方角,而且发现我更喜欢根部更微妙的阴影,所有节点都有非常轻微的阴影。显然,这些更改与 Forest 代码本身无关,因此如果您喜欢,您可以轻松获得那种强烈的阴影、硬边和双线。(在某些情况下,我可能更喜欢它们 - 但显然不是在这种情况下。)
\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{shadows.blur}
\begin{document}
% addaswyd o ateb marmot: https://tex.stackexchange.com/a/436172/
% starting point: https://tex.stackexchange.com/a/341454/121799
\begin{forest}
forked edges,
for tree={font=\sffamily, rounded corners, top color=gray!5, bottom color=gray!10, edge+={darkgray, line width=1pt}, draw=darkgray, align=center, anchor=children},
before packing={where n children=3{calign child=2, calign=child edge}{}},
before typesetting nodes={where content={}{coordinate}{}},
where level<=1{line width=2pt}{line width=1pt},
[1 Clustering Ensemble\\Approaches, blur shadow
[2.1 Generative\\Mechanism
[3.1 Different\\Algorithms]
[3.2 Single\\Algorithms
[4.1 Different built--in\\initialization]
[
[4.3 Different subsets\\of features]
[
[4.5 Different subsets\\of objects]
]
[4.4 Projecting data\\onto different subspaces]
]
[4.2 Different\\parameters]
]
]
[2.2 Consensus\\Function
[3.3 Information Theory\\Approach]
[
[3.5 Voting approach]
[
[3.7 Hypergraph\\methods]
]
[3.6 Mixture Model (EM)]
]
[3.4 Co--association\\based approach]
]
]
\end{forest}
\end{document}