![将直方图绘制为折线图有问题吗?](https://linux22.com/image/307698/%E5%B0%86%E7%9B%B4%E6%96%B9%E5%9B%BE%E7%BB%98%E5%88%B6%E4%B8%BA%E6%8A%98%E7%BA%BF%E5%9B%BE%E6%9C%89%E9%97%AE%E9%A2%98%E5%90%97%EF%BC%9F.png)
我想将一些百分比绘制成折线图,因此我尝试了这个:
\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}