Cómo alinear dos parcelas horizontalmente

Cómo alinear dos parcelas horizontalmente

Quiero alinear estos dos gráficos horizontalmente:

 \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}

y

\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}

Intenté usarlo \subfigurepero sin éxito.

Respuesta1

Así es como lo haría, usando elsubcaptionpaquete como usted desea

captura de pantalla

Me tomé la libertad de mover tu ylabeltexto al título. Yo también lo configuré width=\textwidth.

Quizás quieras explorarlo, scale only axises bastante útil. Lo dejé en el preámbulo como un comentario para que juegues con él.

% 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}

Respuesta2

Normalmente los coloco juntos en un centerentorno:

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

También existe \usepgfplots{groupplots}su disposición matricial asociada, documentada en la Sección 5.5 del pgfplotsmanual.

información relacionada