以下代码展示了一种丑陋的方式来修复自上而下的系统发育图中标签的错误垂直定位。如何避免手动进行特殊的修复?如何找到要修复的良好样式?
% Source: https://tex.stackexchange.com/a/133237/6880
\documentclass[12 pt]{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{phylogenetics}
\pgfgdset{
phylogenetic inner node/.style = {
/tikz/.cd,
draw, circle,
inner sep=0pt,
minimum size=5pt
}
}
\begin{document}
\begin{tikzpicture}
\graph[
phylogenetic tree layout,
upgma,
distance matrix = {
% a b c d e f g
0 4 9 9 9 9 9 % a
4 0 9 9 9 9 9 % b
9 9 0 2 7 7 7 % c
9 9 2 0 7 7 7 % d
9 9 7 7 0 3 5 % e
9 9 7 7 3 0 5 % f
9 9 7 7 5 5 0 % g
}]
{ a, b, c, d, e, f, g };
\end{tikzpicture}
\begin{tikzpicture}[
test/.append style={font=\vphantom{Vg}}
]
\graph[
phylogenetic tree layout,
upgma,
distance matrix = {
% a b c d e f g
0 4 9 9 9 9 9 % a
4 0 9 9 9 9 9 % b
9 9 0 2 7 7 7 % c
9 9 2 0 7 7 7 % d
9 9 7 7 0 3 5 % e
9 9 7 7 3 0 5 % f
9 9 7 7 5 5 0 % g
}]
{ a[test], b[test], c[test], d[test], e[test], f[test], g[test] };
\end{tikzpicture}
\end{document}
答案1
text height
您可以设置一些合理的选项every node
(此外,根据使用情况,设置text depth
也是一个好主意):
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{phylogenetics}
\pgfgdset{
phylogenetic inner node/.style={
/tikz/.cd, draw, circle, inner sep=0pt, minimum size=5pt
}
}
\tikzset{
every node/.style={text height=1.25ex}
}
\begin{document}
\begin{tikzpicture}
\graph[phylogenetic tree layout,
upgma,
distance matrix = {
0 4 9 9 9 9 9
4 0 9 9 9 9 9
9 9 0 2 7 7 7
9 9 2 0 7 7 7
9 9 7 7 0 3 5
9 9 7 7 3 0 5
9 9 7 7 5 5 0 }]
{ a, b, c, d, e, f, g };
\end{tikzpicture}
\end{document}
为什么这有帮助?通过临时向节点添加边框,您可以最好地看到效果:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{phylogenetics}
\pgfgdset{
phylogenetic inner node/.style={
/tikz/.cd, draw, circle, inner sep=0pt, minimum size=5pt
}
}
\tikzset{
every node/.style={text height=1.5ex, text depth=0.33ex, draw}
}
\begin{document}
\begin{tikzpicture}
\graph[phylogenetic tree layout,
upgma,
distance matrix = {
0 4 9 9 9 9 9
4 0 9 9 9 9 9
9 9 0 2 7 7 7
9 9 2 0 7 7 7
9 9 7 7 0 3 5
9 9 7 7 3 0 5
9 9 7 7 5 5 0 }]
{ a, b, c, d, e, f, g };
\end{tikzpicture}
\end{document}
未text depth
设置:
未设置text height
(且未text depth
设置):