在三列中显示重要性水平

在三列中显示重要性水平

我有一项实验的数据,该实验由三种处理方法组成,A、B、C。我想在表格中以紧凑的方式显示 A/B、A/C 和 B/C 的统计测试(例如 t 检验)的结果。这是一个示例空表。

\begin{center}
\begin{tabular}{lccc}
                   &  Control   & Treatment1 & Treatment2 \\
\textbf{Measure 1} &     24     &    28      &    13      \\
\textbf{Measure 2} &     12     &    13      &    21
\end{tabular}
\end{center}

我想以图形方式显示表示 A 和 B 之间差异的星号,比如说在 A 和 B 之间用箭头表示;B 和 C 之间也是一样;但对于 A/CI,需要一种更长的箭头,可以“越过”B。

下面是我想要获得的图形示例。

三种治疗方法有统计学差异

有没有办法在纯乳胶(无 tiKz)中获得这个结果?或者有没有其他关于如何传达 2 种以上治疗的统计检验含义的想法?

谢谢!

答案1

这是一个非 TikZ 方法。事实上它根本不需要额外的包。

在此处输入图片描述

\documentclass{article}
% a fill with arrows to given size, but hide width
\newcommand\doublearrowfill[2]{\makebox[0.7em][c]{\makebox[#2][c]{\leftarrowfill{#1}\rightarrowfill}}}
% commands for the significance arrows
\newcommand\sig  {\doublearrowfill{$\ast$}{2cm}}
\newcommand\sigg {\doublearrowfill{$\ast\ast$}{2cm}}
\newcommand\siggg{\doublearrowfill{$\ast\ast\ast$}{2cm}}
\newcommand\Sig  {\doublearrowfill{$\ast$}{62mm}}
\newcommand\Sigg {\doublearrowfill{$\ast\ast$}{62mm}}
\newcommand\Siggg{\doublearrowfill{$\ast\ast\ast$}{62mm}}
% make headings same size and set in bold face
\newcommand\tabhead[1]{\makebox[2cm][c]{\textbf{#1}}}
\begin{document}
\begin{tabular}{lccccc}
    &\tabhead{Control}&&\tabhead{Treatment 1}&&\tabhead{Treatment 2}\\
    \textbf{Measure 1} & 24 & \sig & 28 & \siggg & 13\\
    \textbf{Measure 2} & 12 &      & 13 & \sigg  & 21\\
    &&&\Siggg
\end{tabular}
\end{document}

再稍微花点功夫,长箭上的箭头就可以做成向上的刻度。

答案2

这是一个使用的解决方案\tikzmark

在此处输入图片描述

如果使用booktabs需要留出一些额外的空间\bottomrule

在此处输入图片描述

代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\tikzset{AST style/.style={fill=white}}
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,anchor=base] \node (#1) {#2};}
\newcommand{\ThreeAst}{${\ast}{\ast}{\ast}$}

\begin{document}
{\centering%
\begin{tabular}{lccc}
                   &  Control   & Treatment1 & Treatment2 \\
\textbf{Measure 1} &     \tikzmark{M1 Control}{24}     &  \tikzmark{M1 Treat1}{28}      &    \tikzmark{M1 Treat2}{13}      \\
\textbf{Measure 2} &     \tikzmark{M2 Control}{12}     &    \tikzmark{M2 Treat1}{13}      &    \tikzmark{M2 Treat2}{21}
\end{tabular}\par}
\begin{tikzpicture}[overlay,remember picture,blue, thick]%
    \draw [stealth-stealth] (M1 Control) -- (M1 Treat1) node[pos=0.5, AST style] {$\ast$};
    \draw [stealth-stealth] (M1 Treat1)  -- (M1 Treat2) node[pos=0.5, AST style] {\ThreeAst};
    \draw [stealth-stealth] (M2 Treat1)  -- (M2 Treat2) node[pos=0.5, AST style] {\ThreeAst};
    \coordinate (M2 Control Extended) at ($(M2 Control.south)+(0pt,-0.75ex)$);
    \coordinate (M2 Treat2 Extended)  at ($(M2 Treat2.south) +(0pt,-0.75ex)$);
    \draw (M2 Control.south) -- (M2 Control Extended) 
        -- (M2 Treat2 Extended) -- (M2 Treat2.south);
    \node [below, AST style] at ($(M2 Treat1)+(0pt,-0.75ex)$) {\ThreeAst};
\end{tikzpicture}
\end{document}

代码:booktabs

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{booktabs}

\tikzset{AST style/.style={fill=white, text=red, outer sep=0pt}}
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,anchor=base] \node (#1) {#2};}
\newcommand{\ThreeAst}{${\ast}{\ast}{\ast}$}

\begin{document}
{\centering%
\begin{tabular}{lccc}\toprule
                   &  \textbf{Control}   & \textbf{Treatment1} & \textbf{Treatment2} \\
                   \cmidrule(lr){2-2}
                   \cmidrule(lr){3-3}
                   \cmidrule(lr){4-4}
\textbf{Measure 1} &     \tikzmark{M1 Control}{24}     &  \tikzmark{M1 Treat1}{28}      &    \tikzmark{M1 Treat2}{13}      \\
\textbf{Measure 2} &     \tikzmark{M2 Control}{12}     &    \tikzmark{M2 Treat1}{13}      &    \tikzmark{M2 Treat2}{21} \\[1.5ex]
\bottomrule
\end{tabular}\par}
\begin{tikzpicture}[overlay,remember picture,blue, thick]%
    \draw [stealth-stealth] (M1 Control) -- (M1 Treat1) node[pos=0.5, AST style] {$\ast$};
    \draw [stealth-stealth] (M1 Treat1)  -- (M1 Treat2) node[pos=0.5, AST style] {\ThreeAst};
    \draw [stealth-stealth] (M2 Treat1)  -- (M2 Treat2) node[pos=0.5, AST style] {\ThreeAst};
    \coordinate (M2 Control Extended) at ($(M2 Control.south)+(0pt,-0.75ex)$);
    \coordinate (M2 Treat2 Extended)  at ($(M2 Treat2.south) +(0pt,-0.75ex)$);
    \draw (M2 Control.south) -- (M2 Control Extended) 
        -- (M2 Treat2 Extended) -- (M2 Treat2.south);
    \node [below, AST style] at ($(M2 Treat1)+(0pt,-0.75ex)$) {\ThreeAst};
\end{tikzpicture}
\end{document}

答案3

这是通过的一次尝试xy-pictiz-cd因为它们具有可以满足需求的表状结构。

在此处输入图片描述

代码

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[all,cmtip]{xy}
\usepackage{tikz-cd}
\usepackage{amsmath}% http://ctan.org/pkg/stackrel
\begin{document}
\xymatrix@=2pt{
& \textbf{Control} &      &\textbf{Treatment1}  &      &\textbf{Treatment2} \\ 
\textbf{Measure 1} & 24   & \ar[l] \star \ar[r] & 28   &\ar[l] \star\star\star\ar[r]  &   13 \\ 
\textbf{Measure 2} &  12  &  & 13   &   \ar[l] \star\star\star \ar[r]  &  21  \\ 
   &    &       & \ar[ll]\star\star\star \ar[rr]  &                    &  \\           
}
\vspace{2cm}   

\begin{tikzcd}[column sep=25pt, row sep=2pt]\hline
 & \textbf{Control} &      &\textbf{Treatment1}&   &\textbf{Treatment2} \\\hline
\textbf{Measure 1}  &  24  & \ar[l] * \ar[r]   & 28 & \ar[l] *** \ar[r] & 13 \\\hline 
\textbf{Measure 2}  &  12  &                   &  
\ar[ll,shorten >=-0.3cm,yshift=-5pt]\underset{***}{13}\ar[rr,shorten >=-0.3cm,yshift=-5pt]   
& \ar[l] *** \ar[r]  &  21 \\ [-5pt]\hline
\end{tikzcd}
\end{document}

相关内容