두 플롯을 수평으로 정렬하는 방법

두 플롯을 수평으로 정렬하는 방법

이 두 플롯을 수평으로 정렬하고 싶습니다.

 \begin{tikzpicture}
        \begin{axis}[
            xmin=1995,
            xmax=2010,
            ymode=log,
            xtick={1975,1980,...,2015},
            x tick label style={/pgf/number format/1000 sep=},
            xlabel={Year},
            ylabel={Cost of gene synthesis $(\$/base$)},
        ]
            \addplot coordinates {(1998,30) (2001,15) (2002,10) (2003,5) (2006,0) (2007,0.7)};
        \end{axis}
    \end{tikzpicture}

그리고

\begin{tikzpicture}
        \begin{axis}[
            xmin=1975,
            xmax=2010,
            ymode=log,
            xtick={1975,1980,...,2015},
            x tick label style={/pgf/number format/1000 sep=},
            xlabel={Year},
            ylabel={Length in base pairs},
        ]
            \addplot coordinates {(1978,207) (1990,2100) (1995,2700) (2003,7500) (2005,14600) (2006,32000) (2009,583000)};
        \end{axis}
    \end{tikzpicture}

사용하려고 했지만 \subfigure성공하지 못했습니다.

답변1

다음은subcaption원하는대로 패키지

스크린샷

ylabel귀하의 텍스트를 캡션으로 자유롭게 옮겼습니다 . 나도 설정했다 width=\textwidth.

당신은 그것이 매우 유용하다는 것을 탐구하고 싶을 수도 있습니다. scale only axis나는 당신이 가지고 놀 수 있도록 서문에 코멘트로 남겨 두었습니다.

% arara: pdflatex
% !arara: indent: {overwrite: true}
\documentclass{article}

\usepackage{pgfplots}
\usepackage{subcaption}

%\pgfplotsset{every axis/.append style={
%                    scale only axis,       % otherwise width won't be as intended: http://tex.stackexchange.com/questions/36297/pgfplots-how-can-i-scale-to-text-width
%                    }}

\begin{document}

\begin{figure}[!ht]
    \begin{subfigure}[t]{.5\textwidth}
        \begin{tikzpicture}
            \begin{axis}[
                    xmin=1995,
                    xmax=2010,
                    ymode=log,
                    xtick={1975,1980,...,2015},
                    x tick label style={/pgf/number format/1000 sep=},
                    xlabel={Year},
                    width=\textwidth,
                ]
                \addplot coordinates {(1998,30) (2001,15) (2002,10) (2003,5) (2006,0) (2007,0.7)};
            \end{axis}
        \end{tikzpicture}
        \caption{Cost of gene synthesis ($\$/base$)},
    \end{subfigure}%
    \begin{subfigure}[t]{.5\textwidth}
        \begin{tikzpicture}
            \begin{axis}[
                    xmin=1975,
                    xmax=2010,
                    ymode=log,
                    xtick={1975,1985,...,2015},
                    x tick label style={/pgf/number format/1000 sep=},
                    xlabel={Year},
                    width=\textwidth,
                ]
                \addplot coordinates {(1978,207) (1990,2100) (1995,2700) (2003,7500) (2005,14600) (2006,32000) (2009,583000)};
            \end{axis}
        \end{tikzpicture}
        \caption{Length in base pairs}
    \end{subfigure}%
\end{figure}
\end{document}

답변2

저는 보통 다음과 같은 center환경에 함께 배치합니다.

\begin{center}
 \begin{tikzpicture} \begin{axis} ... \end{axis} \end{tikzpicture}
 \hfil
 \begin{tikzpicture} \begin{axis} ... \end{axis} \end{tikzpicture}
\end{center}

\usepgfplots{groupplots}매뉴얼 의 섹션 5.5에 문서화되어 있는 관련 매트릭스와 같은 배열 도 있습니다 pgfplots.

관련 정보