答案1
以下使用 TikZ 中的节点矩阵:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [
matrix of nodes,
nodes={draw},
column sep=10mm,
row sep=10mm,
] {
|[draw=none]| 5 parameters & & & SGT \\
|[draw=none]| 4 parameters & & SGED & GT & ST \\
|[draw=none]| 3 parameters & SLaplace & GED & SNormal & t & SCauchy \\
|[draw=none]| 2 parameters & Laplace & Uniform & Normal & & Cauchy \\
};
\begin{scope}[
font=\footnotesize,
inner sep=.25em,
every node/.style={fill=white},
]
\path
(m-1-4) -- node[pos=.9] (tmp) {$p\rightarrow\infty$} (m-4-3)
;
\draw[densely dashed]
(m-1-4) -- (tmp) -- (m-4-3)
;
\draw
(m-1-4) -- node {$q\rightarrow\infty$} (m-2-3)
(m-1-4) -- node[pos=.7, inner sep=.2em] {$\lambda=0$} (m-2-4)
(m-1-4) -- node {$p=2$} (m-2-5)
(m-2-3) -- node {$p=1$} (m-3-2)
(m-2-3) -- node {$\lambda=0$} (m-3-3)
(m-2-3) -- node {$p=1$} (m-3-2)
(m-2-4) -- node[pos=.225] {$q\rightarrow\infty$} (m-3-3)
(m-2-4) -- node[pos=.225] {$p=2$} (m-3-5)
(m-2-5) -- node[pos=.775] {$q\rightarrow\infty$} (m-3-4)
(m-2-5) -- node[pos=.55] {$\lambda=0$} (m-3-5)
(m-2-5) -- node[pos=.55] {$q=1/2$} (m-3-6)
(m-3-2) -- node {$\lambda=0$} (m-4-2)
(m-3-3) -- node {$p=1$} (m-4-2)
(m-3-3) -- node[pos=.6] {$p=2$} (m-4-4)
(m-3-4) -- node {$\lambda=0$} (m-4-4)
(m-3-5) -- node {$q\rightarrow\infty$} (m-4-4)
(m-3-5) -- node {$q=1/2$} (m-4-6)
(m-3-6) -- node {$\lambda=0$} (m-4-6)
;
\end{scope}
\end{tikzpicture}
\end{document}
当然,不用白色背景也是可以的:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [
matrix of nodes,
nodes={draw},
column sep=10mm,
row sep=10mm,
] {
|[draw=none]| 5 parameters & & & SGT \\
|[draw=none]| 4 parameters & & SGED & GT & ST \\
|[draw=none]| 3 parameters & SLaplace & GED & SNormal & t & SCauchy \\
|[draw=none]| 2 parameters & Laplace & Uniform & Normal & & Cauchy \\
};
\begin{scope}[
font=\footnotesize,
inner sep=.25em,
line cap=round,
]
\newcommand*{\LINE}[4][.5]{%
\path (m-#2) -- node[pos=#1] (tmp) {$#4$} (m-#3);
\draw (m-#2) -- (tmp) -- (m-#3);
}
\LINE {1-4}{2-3}{q\rightarrow\infty}
\LINE[.7] {1-4}{2-4}{\lambda=0}
\LINE{1-4} {2-5}{p=2}
\LINE {2-3}{3-2}{p=1}
\LINE {2-3}{3-3}{\lambda=0}
\LINE {2-3}{3-2}{p=1}
\LINE[.225]{2-4}{3-3}{q\rightarrow\infty}
\path
(tmp.south west) coordinate (gt1ll)
(tmp.north east) coordinate (gt1ur)
;
\LINE[.225]{2-4}{3-5}{p=2}
\LINE[.775]{2-5}{3-4}{q\rightarrow\infty}
\LINE[.55] {2-5}{3-5}{\lambda=0}
\LINE[.55] {2-5}{3-6}{q=1/2}
\LINE {3-2}{4-2}{\lambda=0}
\LINE {3-3}{4-2}{p=1}
\LINE[.6] {3-3}{4-4}{p=2}
\LINE {3-4}{4-4}{\lambda=0}
\LINE {3-5}{4-4}{q\rightarrow\infty}
\LINE {3-5}{4-6}{q=1/2}
\LINE {3-6}{4-6}{\lambda=0}
;
\begin{scope}
\clip
(m-1-1) rectangle (m-4-6)
(gt1ll) rectangle (gt1ur)
;
\path
(m-1-4) -- node[pos=.9] (tmp) {$p\rightarrow\infty$} (m-4-3)
;
\draw[densely dashed]
(m-1-4) -- (tmp) -- (m-4-3)
;
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
以下变体更改了虚线以避免与其他标签交叉。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [
matrix of nodes,
nodes={draw},
column sep=10mm,
row sep=10mm,
] {
|[draw=none]| 5 parameters & & & SGT \\
|[draw=none]| 4 parameters & & SGED & GT & ST \\
|[draw=none]| 3 parameters & SLaplace & GED & SNormal & t & SCauchy \\
|[draw=none]| 2 parameters & Laplace & Uniform & Normal & & Cauchy \\
};
\begin{scope}[
font=\footnotesize,
inner sep=.25em,
line cap=round,
]
\newcommand*{\LINE}[4][.5]{%
\path (m-#2) -- node[pos=#1] (tmp) {$#4$} (m-#3);
\draw (m-#2) -- (tmp) -- (m-#3);
}
\LINE[.55] {1-4}{2-3}{q\rightarrow\infty}
\LINE {1-4}{2-4}{\lambda=0}
\LINE {1-4}{2-5}{p=2}
\LINE {2-3}{3-2}{p=1}
\LINE {2-3}{3-3}{\lambda=0}
\LINE {2-3}{3-2}{p=1}
\LINE[.225]{2-4}{3-3}{q\rightarrow\infty}
\path
(tmp.south west) coordinate (gt1ll)
(tmp.north east) coordinate (gt1ur)
;
\LINE[.225]{2-4}{3-5}{p=2}
\LINE[.775]{2-5}{3-4}{q\rightarrow\infty}
\LINE[.55] {2-5}{3-5}{\lambda=0}
\LINE[.55] {2-5}{3-6}{q=1/2}
\LINE {3-2}{4-2}{\lambda=0}
\LINE {3-3}{4-2}{p=1}
\LINE[.6] {3-3}{4-4}{p=2}
\LINE {3-4}{4-4}{\lambda=0}
\LINE {3-5}{4-4}{q\rightarrow\infty}
\LINE {3-5}{4-6}{q=1/2}
\LINE {3-6}{4-6}{\lambda=0}
\path
(m-2-3.center) -- coordinate[pos=.45] (tmp1) (m-2-4.center)
(m-3-3.center) -- coordinate[pos=.45] (tmp2) (m-3-4.center)
(tmp2) -- node[pos=.7] (tmp3) {$p\rightarrow\infty$} (m-4-3)
;
\draw[densely dashed]
(m-1-4) -- (tmp1) -- (tmp2) -- (tmp3) (tmp3) -- (m-4-3)
;
\end{scope}
\end{tikzpicture}
\end{document}
答案2
以下是我的做法:
\documentclass[tikz]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xfrac}
\begin{document}
\tikzset{
justtext/.style = {
rectangle,
fill = none,
draw = none,
inner sep = 0pt,
line width = 0pt,
minimum width = 0pt,
minimum height = 0pt
},
lbl/.style = {
justtext,
midway,
font = \small,
fill = white,
inner sep = 0.5ex
}
}
% [#1] Options for label.
% #2 Node 1.
% #3 Node 2.
% #4 Label text; will be put in math mode.
\newcommand{\link}[4][]{%
\draw (#2) -- node[lbl, #1] {$#4$} (#3);%
}
\begin{tikzpicture}[
x = 2.75cm,
y = 2cm,
every node/.style = {
draw,
thick,
minimum width = 5em,
minimum height = 4ex,
}
]
\foreach \i in {2, ..., 5}
\node[justtext] at (0, \i - 2) {\i~parameters};
\node (la) at (1, 0) {Laplace};
\node (un) at (2, 0) {Uniform};
\node (no) at (3, 0) {Normal};
\node (ca) at (5, 0) {Cauchy};
\node (sl) at (1, 1) {SLaplace};
\node (ge) at (2, 1) {GED};
\node (sn) at (3, 1) {SNormal};
\node (t) at (4, 1) {t};
\node (sc) at (5, 1) {SCauchy};
\node (sg) at (2, 2) {SGED};
\node (gt) at (3, 2) {GT};
\node (st) at (4, 2) {ST};
\node (sgt) at (3, 3) {SGT};
\link{la}{sl}{\lambda = 0}
\link{la}{ge}{p = 1}
\link{no}{ge}{p = 2}
\link{no}{sn}{\lambda = 0}
\link{no}{t}{q \to \infty}
\link{ca}{t}{q = \sfrac{1}{2}}
\link{ca}{sc}{\lambda = 0}
\link{sl}{sg}{p = 1}
\link{ge}{sg}{\lambda = 0}
\link[pos = 0.2]{ge}{gt}{q \to \infty}
\link[pos = 0.2]{sn}{sg}{p = 2}
\link[pos = 0.2]{sn}{st}{q \to \infty}
\link{t}{st}{\lambda = 0}
\link[pos = 0.2]{t}{gt}{p = 2}
\link{sc}{st}{q = \sfrac{1}{2}}
\link{sg}{sgt}{q \to \infty}
\link{gt}{sgt}{\lambda = 0}
\link{st}{sgt}{p = 2}
\begin{scope}[draw = gray, dashed]
\link[pos = 0.1]{un.east}{sgt.west}{p \to \infty}
\end{scope}
\end{tikzpicture}
\end{document}
tikz
请注意,在普通文档类中,当然必须添加包。xfrac
仅用于\sfrac
1/2 内容的命令;可能有点过头,但看起来更漂亮。
我创建了两种节点样式:一种用于没有绘制任何内容的文本块,一种用于边缘上的标签。我使用 来\foreach
编写左侧的内容,因为这样更有趣;它为您提供了一个 foreach 的示例,并且由于样式和文本等仅编写一次,因此它使代码更容易修改。我还修改了默认节点样式,但仅适用于此特定tikzpicture
环境。此外,x
和y
允许您调整比例和内容。
对于边,我创建了一个命令\link
,用于连接两个节点并在边上写入数学内容。一个可选参数允许用户向标签节点提供其他内容;我使用此可选参数在边交叉的情况下将标签定位到更靠近边的开头的位置(pos = 0.2
)。
顺便说一句,我写的是“parameterS”,但也许我只是误解了你展示的图片中的文字。我觉得没有这个“s”很奇怪。请随意更改。
答案3
解决方案是pstricks
。它基于 的psmatrix
环境和psDefBoxNodes
命令pst-node
。后者将 12 个节点关联到给定文本的边界框:(tl
左上)、tC
(中上)、tr
(右上)、(Cl
左中Bl
)、(左基线)、bl
(左下)等。基于此命令,我定义了一个\framenode[optional width] nodename}{contents}
命令。默认宽度为 4.5 em:
\documentclass[x11names, border=5pt]{standalone}
\usepackage{pstricks-add, auto-pst-pdf}%
\usepackage{mathtools}
\newcommand{\framenode}[3][4.5em]{\psDefBoxNodes{#2}{\setlength{\fboxrule}{1pt}\fbox{\parbox{#1}{\rule{0pt}{3ex}\centering#3\rule[-1.25ex]{0pt}{1.25ex}}}}}
\begin{document}
\begin{pspicture}
\small\everypsbox{\everymath{\scriptstyle}}
\renewcommand{\pscolhooki}{\psset{mcol=l}}
\begin{psmatrix}[colsep=1cm, rowsep=1.25cm]
5 parameter & & & \framenode{SGT}{SGT} \\
4 parameter & & \framenode{SG}{SGED} & \framenode{GT}{GT} & \framenode{ST}{ST} \\
3 parameter & \framenode{SL}{SLaplace} & \framenode{GE}{GED} & \framenode{SN}{SNormal} & \framenode{T}{t} & \framenode{SC}{SCauchy} \\
2 parameter & \framenode{L}{Laplace} & \framenode{U}{Uniform} & \framenode{N}{Normal} & & \framenode{C}{Cauchy}
\end{psmatrix}
%% Connexions
\psset{linewidth=0.4pt, framesep=3pt, ref=r}
% Niveau 1
\ncline{SGT:Cl}{SG:tC}\ncput*[framesep=1pt, ref=c]{$q\to∞$}
\ncline{SGT:bC}{GT:tC}\ncput*{$λ=\mathrlap{0}$}
\ncline{SGT:Cr}{ST:tC}\ncput*{$ p=\mathrlap{2}$}
\ncline[linestyle=dashed, dash=2pt 2pt]{SGT:Cl}{U:Cr}\ncput*[framesep=1pt, ref=c, npos=0.85]{$p\to∞$}
%Niveau 2
\ncline{SG:Cl}{SL:tC}\ncput*{$p=\mathrlap{1}$}
\ncline{SG:bC}{GE:tC}\ncput*{$λ=\mathrlap{0}$}
\ncline{SG:Cr}{SN:tC}\ncput*[npos=0.8]{$ p=\mathrlap{2}$}
\ncline{GT:Cl}{GE:tC}\ncput*[framesep=1pt, ref=c]{$q\to∞$}
\ncline{GT:Cr}{T:tC}\ncput*{$ p=\mathrlap{2}$}
\ncline{ST:Cl}{SN:tC}\ncput*[framesep=1pt, ref=c]{$q\to∞$}
\ncline{ST:bC}{T:tC}\ncput*{$λ=\mathrlap{0}$}
\ncline{ST:Cr}{SC:tC}\ncput*{$q=1\mkern-2mu/\mkern-1.5mu\mathrlap{2}$}
% Niveau 3
\ncline{SL:bC}{L:tC}\ncput*{$λ=\mathrlap{0}$}
\ncline{GE:Cl}{L:tC}\ncput*{$p=\mathrlap{1}$}
\ncline{GE:Cr}{N:tC}\ncput*{$ p=\mathrlap{2}$}
\ncline{SN:bC}{N:tC}\ncput*{$λ=\mathrlap{0}$}
\ncline{T:Cl}{N:tC}\ncput*[framesep=1pt, ref=c]{$q\to∞ $}
\ncline{T:Cr}{C:tC}\ncput*{$q=1\mkern-2mu/\mkern-1.5mu\mathrlap{2}$}
\ncline{SC:bC}{C:tC}\ncput*{$λ=\mathrlap{0}$}
\end{pspicture}
\end{document}