如何将此图按 2 样式分组?

如何将此图按 2 样式分组?

我有以下图表来说明性能:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[legend style={at={(.5,0.9)},anchor=north east},
symbolic x coords={Accuracy, score, recall, precision, hamming loss, jaccard similarity, F-beta score}, xtick=data,
x tick label style={rotate=45,anchor=east}]
\addlegendentry{data set 1}
\addplot[mark=*,thick,blue] coordinates {
(Accuracy,1.90129) (score,38.908839) (recall,50.29032309) (precision,28.09321093) (hamming loss,40.3093) (jaccard similarity,80.2323) (F-beta score,78.1920129)
};

\addlegendentry{data set 2}
\addplot[mark=diamond*,thick,red] coordinates {
(Accuracy,12.90129) (score,34.908839) (recall,60.29032309) (precision,22.09321093) (hamming loss,50.3093) (jaccard similarity,90.2323) (F-beta score,89.1920129)
};


\end{axis}
\end{tikzpicture}
\end{document}

我怎样才能在一页中以 2x2 样式绘制 4 个这样的图?

答案1

您可以groupplots使用pgfplots

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
group style={
group name=my plots,
group size=2 by 2,
xlabels at=edge bottom,
ylabels at=edge left,
horizontal sep=2cm,vertical sep=3cm,
},
legend style={at={(.5,0.9)},anchor=north east},
symbolic x coords={Accuracy, score, recall, precision, hamming loss, jaccard similarity, F-beta score}, xtick=data,
x tick label style={rotate=45,anchor=east},
width=0.5\linewidth
]
\nextgroupplot
\addlegendentry{data set 1}
\addplot[mark=*,thick,blue] coordinates {
(Accuracy,1.90129) (score,38.908839) (recall,50.29032309) (precision,28.09321093) (hamming loss,40.3093) (jaccard similarity,80.2323) (F-beta score,78.1920129)
};
\addlegendentry{data set 2}
\addplot[mark=diamond*,thick,red] coordinates {
(Accuracy,12.90129) (score,34.908839) (recall,60.29032309) (precision,22.09321093) (hamming loss,50.3093) (jaccard similarity,90.2323) (F-beta score,89.1920129)
};

\nextgroupplot
\addlegendentry{data set 1}
\addplot[mark=*,thick,blue] coordinates {
(Accuracy,1.90129) (score,38.908839) (recall,50.29032309) (precision,28.09321093) (hamming loss,40.3093) (jaccard similarity,80.2323) (F-beta score,78.1920129)
};
\addlegendentry{data set 2}
\addplot[mark=diamond*,thick,red] coordinates {
(Accuracy,12.90129) (score,34.908839) (recall,60.29032309) (precision,22.09321093) (hamming loss,50.3093) (jaccard similarity,90.2323) (F-beta score,89.1920129)
};

\nextgroupplot
\addlegendentry{data set 1}
\addplot[mark=*,thick,blue] coordinates {
(Accuracy,1.90129) (score,38.908839) (recall,50.29032309) (precision,28.09321093) (hamming loss,40.3093) (jaccard similarity,80.2323) (F-beta score,78.1920129)
};
\addlegendentry{data set 1}
\addplot[mark=*,thick,blue] coordinates {
(Accuracy,1.90129) (score,38.908839) (recall,50.29032309) (precision,28.09321093) (hamming loss,40.3093) (jaccard similarity,80.2323) (F-beta score,78.1920129)
};

\nextgroupplot
\addlegendentry{data set 1}
\addplot[mark=*,thick,blue] coordinates {
(Accuracy,1.90129) (score,38.908839) (recall,50.29032309) (precision,28.09321093) (hamming loss,40.3093) (jaccard similarity,80.2323) (F-beta score,78.1920129)
};
\addlegendentry{data set 2}
\addplot[mark=diamond*,thick,red] coordinates {
(Accuracy,12.90129) (score,34.908839) (recall,60.29032309) (precision,22.09321093) (hamming loss,50.3093) (jaccard similarity,90.2323) (F-beta score,89.1920129)
};


\end{groupplot}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容