我的 TikZ 图片无法并排对齐

我的 TikZ 图片无法并排对齐

以下是我目前的 LaTeX 代码:

\documentclass{article}
\usepackage{pgfplots}
\usepackage{subcaption}
\captionsetup{compatibility=false}

\begin{document}
\begin{figure}

 \begin{subfigure}[b]{0.5\textwidth}
  \centering
  \resizebox{\linewidth}{!}{
   \begin{tikzpicture}
   \begin{axis}[
    title={Color},
    xlabel={Number of annotations per task},
    ylabel={Error rate (\%)},
    xmin=3, xmax=10,
    ymin=0, ymax=11,
    xtick={3,4,5,6,7,8,9,10},
    ytick={0,2,4,6,8,10,11},
    legend pos=north west,
    %ymajorgrids=true,
    %grid style=dashed,
]

   \addplot[
    color=blue,
    mark=square,
    ]
    coordinates {
    (3,08.86)(4,06.88)(5,05.10)(6,02.81)(7,02.38)(8,01.73)(9,00.65)(10,00.65)
    };
    \legend{Majority Voting}

   \end{axis}
   \end{tikzpicture}
   }
 \end{subfigure}

\begin{subfigure}[b]{0.5\textwidth}
\centering
\resizebox{\linewidth}{!}{
\begin{tikzpicture}
\begin{axis}[
    title={Color},
    xlabel={Number of annotations per task},
    ylabel={Error rate (\%)},
    xmin=3, xmax=10,
    ymin=0, ymax=11,
    xtick={3,4,5,6,7,8,9,10},
    ytick={0,2,4,6,8,10,11},
    legend pos=north west,
    %ymajorgrids=true,
    %grid style=dashed,
]

\addplot[
    color=blue,
    mark=square,
    ]
    coordinates {
    (3,08.86)(4,06.88)(5,05.10)(6,02.81)(7,02.38)(8,01.73)(9,00.65)(10,00.65)
    };
    \legend{Majority Voting}

\end{axis}
\end{tikzpicture}
}
\end{subfigure}
\end{figure}
\end{document}

显示如下:

在此处输入图片描述

答案1

在此处输入图片描述

只需删除段落分隔符并使用

 \end{subfigure}\begin{subfigure}[b]{0.5\textwidth}

相关内容