表格无法提供两个大小相同的数字

表格无法提供两个大小相同的数字

我制作了两个箱线图。

Amplification.tex

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}
  \begin{axis}
    [title = {Amplitude of Focal and Arm-level SCNAs},ylabel = {$log_{2}(I_{C}/I_{N})$},
    boxplot/draw direction=y,
    xtick={1,2},
    xticklabels={Focal, Arm}
    ]
    \addplot+[mark options = {red},
    boxplot prepared={
      lower whisker=0.1000546,
      lower quartile=0.1615851,
      median=0.2402481,
      upper quartile=0.4031734,
      upper whisker=0.7642697
    }, color = red
    ] table[col sep=comma] {FocalAmpRemaining.csv};
     \addplot+[mark = *,mark options = {red},
    boxplot prepared={
     lower whisker=0.1035846,
     lower quartile=0.1141071,
     median=0.1301499,
     upper quartile=0.2035154,
     upper whisker=0.2652706
    }, color = red
    ] coordinates {(0,0.4313409)};
    \draw[black, dashed]
      (axis cs:0, 0.1) coordinate (tmp)
      (current axis.west |- tmp) -- (current axis.east |- tmp);
    \end{axis}
\end{tikzpicture}
\end{document}

deletion.tex

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}
  \begin{axis}
    [title = {Deletion of Focal and Arm-level SCNAs},ylabel = {$log_{2}(I_{C}/I_{N})$},
    boxplot/draw direction=y,
    xtick={1,2},
    xticklabels={Focal, Arm}
    ]
    \addplot+[mark options = {blue},
    boxplot prepared={
      lower whisker=-0.9197604,
      lower quartile=-0.4621040,
      median=-0.2362183,
      upper quartile=-0.1566109,
      upper whisker=-0.1003486
    }, color = blue 
    ] coordinates {};
     \addplot+[mark = *,mark options = {blue},
    boxplot prepared={
     lower whisker=-0.2970707,
     lower quartile=-0.2019435,
     median=-0.1603655,
     upper quartile=-0.1199740,
     upper whisker=-0.1012605
    }, color = blue
    ] coordinates {(0,-0.3299711)(0,-0.3299711)(0,-0.3642782)(0,-0.3930741)(0,-0.4372732)(0,-0.6161027)};
     \draw[black, dashed]
      (axis cs:0, -0.1) coordinate (tmp)
      (current axis.west |- tmp) -- (current axis.east |- tmp);
    \end{axis}
\end{tikzpicture}
\end{document}

我将两张图片都保存为 pdf,重新上传到 latex 中,并尝试使用 将它们组合起来tabular。但是,它们的尺寸不一致。怎么会这样呢?谢谢!

\documentclass[12pt,a4paper,twoside]{standalone}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{pgfplots}
\graphicspath{{./Figures/}}
\begin{document}        
\begin{tabular}{ll}
\includegraphics[width=\textwidth]{amplification.pdf} &
\includegraphics[width=\textwidth]{deletion.pdf} \\
{\Large\textbf{(A)}} & {\Large\textbf{(B)}} \\
\end{tabular}
\end{document}

在此处输入图片描述

答案1

问题似乎是您的图表的纵横比不同(我不知道,因为我没有您的 csv,所以我无法重新创建它们),因此将它们设置为相同的宽度不会使它们的高度相同。请注意,左侧图表的左侧有一个数字宽度的标签,但右侧图表有四个字符宽度的标签 - 这可能是区别。您可以同时指定图表的宽度和高度,但这是一个糟糕的解决方案,因为它会拉伸它们。

最简单的方法是将它们设置为相同的高度,这样看起来就正确了:

\documentclass[12pt,a4paper,twoside]{standalone}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{pgfplots}

\graphicspath{{./Figures/}}
\begin{document}        
    \begin{tabular}{ll}
        \includegraphics[height=.5\linewidth]{example-image-1x1.pdf} &
        \includegraphics[height=.5\linewidth]{example-image.pdf} \\
        {\Large\textbf{(A)}} & {\Large\textbf{(B)}} \\
    \end{tabular}
\end{document}

在此处输入图片描述

但是在文档中,您的表格方法会弄乱您的边距,而且由于您指定了纸张尺寸,twoside听起来您想要一个文档?

对于这种情况,您可能需要手动将它们放在一起:

\documentclass[12pt,a4paper,twoside]{book}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{pgfplots}

\usepackage{mwe}
\usepackage{showframe}

\graphicspath{{./Figures/}}
\begin{document}  
    This causes all sorts of margin problems:\bigskip


    \begin{tabular}{ll}
        \includegraphics[height=.5\linewidth]{example-image-1x1.pdf} &
        \includegraphics[height=.5\linewidth]{example-image.pdf} \\
        {\Large\textbf{(A)}} & {\Large\textbf{(B)}} \\
    \end{tabular}

    \vspace{.5in}

    So it may be better to place them manually:\bigskip

    \noindent\includegraphics[height=2.25in]{example-image-1x1}\hfill
    \includegraphics[height=2.25in]{example-image}\par
    \noindent{\Large\textbf{(A)}}\hspace{2in}{\Large\textbf{(B)}}

\end{document}

在此处输入图片描述

我之所以使用\usepackage{mwe}此示例,是因为它会加载所有常见的 LaTeX 发行版中的测试图像,以便轻松共享此类内容。它们是示例 PDF,与您创建的 PDF 并无不同(形状除外)。

答案2

您可以使用groupplots。以下是示例:

\documentclass[margin=5]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepgfplotslibrary{statistics,groupplots}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
         group style={group name=my plots,group size=2 by 1, vertical sep=70pt,horizontal sep=6em,
    ylabels at=edge left
    },
          width=5.2cm,
          height=5.2cm,
      scale only axis,
      scaled ticks = false,
        ]
        \nextgroupplot [title = {\strut Deletion of Focal and Arm-level SCNAs},ylabel = {$log_{2}(I_{C}/I_{N})$},
    boxplot/draw direction=y,
    xtick={1,2},
    xticklabels={Focal, Arm},
    width=5.2cm,
          height=5.2cm,
      %scale only axis,
%      scaled ticks = false,
    ]
    \addplot+[mark options = {blue},
    boxplot prepared={
      lower whisker=-0.9197604,
      lower quartile=-0.4621040,
      median=-0.2362183,
      upper quartile=-0.1566109,
      upper whisker=-0.1003486
    }, color = blue
    ] coordinates {};
     \addplot+[mark = *,mark options = {blue},
    boxplot prepared={
     lower whisker=-0.2970707,
     lower quartile=-0.2019435,
     median=-0.1603655,
     upper quartile=-0.1199740,
     upper whisker=-0.1012605
    }, color = blue
    ] coordinates {(0,-0.3299711)(0,-0.3299711)(0,-0.3642782)(0,-0.3930741)(0,-0.4372732)(0,-0.6161027)};
     \draw[black, dashed]
      (axis cs:0, -0.1) coordinate (tmp)
      (current axis.west |- tmp) -- (current axis.east |- tmp);
   \nextgroupplot [title = {\strut Amplitude of Focal and Arm-level SCNAs},ylabel = {$log_{2}(I_{C}/I_{N})$},
    boxplot/draw direction=y,
    xtick={1,2},
    xticklabels={Focal, Arm},
    width=5.2cm,
          height=5.2cm,
      %scale only axis,
%      scaled ticks = false,
    ]
    \addplot+[mark options = {red},
    boxplot prepared={
      lower whisker=0.1000546,
      lower quartile=0.1615851,
      median=0.2402481,
      upper quartile=0.4031734,
      upper whisker=0.7642697
    }, color = red
    ] table[col sep=comma] {FocalAmpRemaining.csv};
     \addplot+[mark = *,mark options = {red},
    boxplot prepared={
     lower whisker=0.1035846,
     lower quartile=0.1141071,
     median=0.1301499,
     upper quartile=0.2035154,
     upper whisker=0.2652706
    }, color = red
    ] coordinates {(0,0.4313409)};
    \draw[black, dashed]
      (axis cs:0, 0.1) coordinate (tmp)
      (current axis.west |- tmp) -- (current axis.east |- tmp);
    \end{groupplot}
    \node[below=8mm,font=\bfseries\large] at (my plots c1r1.south) {(A)};
    \node[below=8mm,font=\bfseries\large] at (my plots c2r1.south west) {(B)};  %% change south west as you wish
    \end{tikzpicture}


\end{document}

在此处输入图片描述

我对两个情节使用了相同width的内容,并在标题中添加了(因为其中一个标题没有下降部分,而另一个标题没有下降部分)。height\strutp

相关内容