我想将一些百分比绘制成折线图,因此我尝试了这个:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=2.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[legend style={at={(.9,0.9),anchor=north east}},
symbolic x coords={Accuracy, score, recall, precision, hamming loss, jaccard similarity, F-beta score}, xtick=data]
\addlegendentry{data set 1}
\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)
};
\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}
问题在于图表无法容纳这些图。如何解决此问题以便比较两个不同的曲线(数据集)?
答案1
您有版本2.12
? ;-) 制作它1.12
并更改x tick label style
。然后您得到这个:
\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}