2つのプロットを水平に揃える方法

2つのプロットを水平に揃える方法

これら 2 つのプロットを水平に揃えたいと思います。

 \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

関連情報