图像格式化

图像格式化

我该如何创建一个紧凑的两列图形,每列有 3 个图形?这就是我试图这样做造成的混乱。

 \documentclass[a4paper,man,12pt]{scrartcl}
    \setkomafont{disposition}{\normalfont\bfseries}
    \usepackage{geometry}
    \usepackage{siunitx}
    \usepackage[numbers,super]{natbib}
    \usepackage[english]{babel}
    \usepackage{gensymb}
    \usepackage{titling}
    \usepackage{graphicx}
    \graphicspath{ {images/} }
    \usepackage{caption}
    \usepackage{float} 
    \usepackage{xcolor} 
    \usepackage{pgfplots} 
    \usepackage{subcaption}
    \usepackage{amsmath}
    \usepackage{mathptmx}
   \captionsetup{justification =   raggedright,
              singlelinecheck=  false}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{statistics} 
\usepackage[font=small,labelfont=bf,
   justification=justified,
   format=plain]{caption} % 'format=plain' avoids hanging indentation

\geometry{hmargin={1in,1in},height=9in} %adjusts margins

    \begin{document}

    \begin{figure}[H]

    \begin{subfigure}{0.35\textwidth}
    \centering
    \begin{tikzpicture}
    \begin{axis}
        [ylabel =
                {Y-label},
            yticklabels= {1,2,3,4,5,6},
            xlabel={X label},
            ytick={1,2,3,4,5,6},
            x post scale=1.1, enlarge x limits=0.01, width=1.25\textwidth,
            xmin=0,
            xmax=6000000,
            title=title,
            every x tick scale label/.style={at={(xticklabel cs:1)},anchor=south west}
            ]
        \addplot[
        boxplot prepared={
        median=2.5,
        upper quartile=3,
        lower quartile=2,
            upper whisker=5,
            lower whisker=1,
                every box/.style={very thick},
        every whisker/.style={ultra thick},
        every median/.style={ultra thick},
        },
         x post scale=2.0
        ] coordinates {};
    \end{axis}
    \label{Fig:fig1A}
    \end{tikzpicture}

    \end{subfigure}%
    \hbox{\hspace{3.0cm}\begin{subfigure}{0.35\textwidth}
    \begin{tikzpicture}
    \begin{axis}
         [ylabel =
                {Y-label},
            yticklabels= {1,2,3,4,5,6},
            xlabel={X label},
            ytick={1,2,3,4,5,6},
            x post scale=1.1, enlarge x limits=0.01, width=1.25\textwidth,
            xmin=0,
            xmax=6000000,
            title=title,
            every x tick scale label/.style={at={(xticklabel cs:1)},anchor=south west}
            ]
        \addplot[
        boxplot prepared={
        median=2.5,
        upper quartile=3,
        lower quartile=2,
            upper whisker=5,
            lower whisker=1,
                every box/.style={very thick},
        every whisker/.style={ultra thick},
        every median/.style={ultra thick},
        },
         x post scale=2.0
        ] coordinates {};
    \end{axis}
    \label{1C}
    \end{tikzpicture}
    \end{subfigure}}%
    \begin{subfigure}{.5\textwidth}
      \centering
      \hbox{\hspace{-13.25cm}\textbf{2C}}
      \hbox{\hspace{-14.0cm}\vspace{-11.5cm}\includegraphics[width=0.95\linewidth]{Images/Figure2e.png}}

      \label{fig:sub2}
    \end{subfigure}


    \begin{subfigure}{.5\textwidth}
      \centering
      \hbox{\hspace{0.85cm}\textbf{2E}}
      \hbox{\hspace{0.75cm}\vspace{-8.5cm}\includegraphics[width=0.85\linewidth]{Images/Figure2c.png}}
      \label{fig:sub2}
    \end{subfigure}
    \begin{subfigure}{.5\textwidth}
      \centering
      \hbox{\hspace{1.75cm}\textbf{2D}}
      \hbox{\hspace{3.0cm}\vspace{2.5cm}\includegraphics[width=0.75\linewidth]{Images/Figure2b.png}}
      \label{fig:sub2}
    \end{subfigure}
    \begin{subfigure}{0.5\textwidth}
      \centering
      \hbox{\hspace{9.90cm}\textbf{2F}}
      \hbox{\hspace{10.0cm}\vspace{0.0cm}\includegraphics[width=0.75\linewidth]{Images/Figure2f.png}}
      \label{fig:sub2}
    \end{subfigure}

    \caption{Caption}
    \end{figure}
    \end{document}

抱歉,这太乱了,我想几乎完全复制我自己挖的坑。我的问题是,如果我尝试移动某些图形的浮动,它们只会围绕其下方的文本移动,而不是图形本身。此外,图形之间有太多空白。 在此处输入图片描述

答案1

太长了,无法在评论中容纳……

  • 从你的问题来看不清楚你的问题是什么:
    • 定位数字
    • 定位子标题
    • \pgfplots用...绘制图表
  • 到目前为止,我已经能够将您的代码(如您所说的那样混乱)简化为以下 mwe(最小工作示例):

    \documentclass[a4paper,man,12pt]{scrartcl}
    \usepackage[hmargin=1in,height=9in]{geometry}
    \usepackage[demo]{graphicx}
    \usepackage{pgfplots}
    \usepackage{subcaption}
    \pgfplotsset{compat=1.16}
    \usepgfplotslibrary{statistics}
    \usepackage[font=small,
                labelfont=bf,
                justification=justified,
                format=plain]{caption} % 'format=plain' avoids hanging indentation
    
    \usepackage{lipsum}
    \begin{document}
    \lipsum[1]
    
    \begin{figure}[htb]
        \centering
    \begin{subfigure}{.45\textwidth}
        \caption{first \texttt{pgfplot} diagram}
        \label{fig:sub1}
    \begin{tikzpicture}
    \begin{axis}[
    width=\textwidth,       % don't prescibe digram width larger as available space!
    ylabel = {Y-label},
    xlabel={X label},
    enlarge x limits=0.01,
    xmin=0, xmax=6000000,
    grid
                ]
        \addplot coordinates {(0,0) (6000000,6)};
    \end{axis}
    \end{tikzpicture}
    \end{subfigure}
    \hfil
    \begin{subfigure}{.45\textwidth}
        \caption{second \texttt{pgfplot} diagram}
        \label{fig:sub2}
    \begin{tikzpicture}
    \begin{axis}[
    width=\textwidth,       % don't prescibe digram width larger as available space!
    ylabel = {Y-label},
    xlabel={X label},
    enlarge x limits=0.01,
    xmin=0, xmax=6000000,
    grid
                ]
        \addplot coordinates {(0,6) (6000000,0)};
    \end{axis}
    \end{tikzpicture}
    \end{subfigure}
    
    \begin{subfigure}{.45\textwidth}
    \includegraphics[width=\linewidth]{Images/Figure2e.png}
        \caption{first}
        \label{fig:sub1}
    \end{subfigure}
    \hfil
    \begin{subfigure}{.45\textwidth}
    \includegraphics[width=\linewidth]{Images/Figure2c.png}
        \caption{second}
        \label{fig:sub2}
    \end{subfigure}
    
    \begin{subfigure}{.45\textwidth}
    \includegraphics[width=\linewidth]{Images/Figure2b.png}
        \caption{third}
        \label{fig:sub3}
    \end{subfigure}
    \hfil
    \begin{subfigure}{0.45\textwidth}
        \centering
    \includegraphics[width=\linewidth]{Images/Figure2f.png}
        \caption{fourth}
        \label{fig:sub2}
    \end{subfigure}
        \caption{Caption}
    \end{figure}
    \end{document}
    

    产生以下结果:

在此处输入图片描述

请澄清一下您的期望。最好借助一些草图或上述 mwe 的帮助。

编辑: 添加使用该pgfplots包绘制的图表(虚拟)示例。观察图表的宽度是如何定义的。它不应大于保留空间的宽度subfigure

相关内容