我有以下 latex 代码,在我的其中一台机器上运行良好,但在其他机器上却无法运行(Ubuntu16 和 Ubuntu14;可能安装了不同版本的 latex)。我怀疑存在 pgfplot 兼容性问题。我想知道是否有人可以帮助我在我的 Ubuntu 14 机器上解决这个问题,因为另一台机器坏了:
\documentclass[12pt]{article} \linespread{1.65}
\usepackage{subfigure}
\usepackage{pgfplots}
\usepackage{arrayjob}
\newcommand{\plotprh}[3] {
\subfigure[$\ell=#1$]{%
\begin{tikzpicture}
\begin{axis}[
height=4.2cm,
width=5.5cm,
xlabel={$k'$},
ylabel={Percent (\%)},
legend pos=north west,
legend cell align=left,
ymin=0,
ylabel style={at={(0.09,0.5)},font=\small},
xlabel style={at={(0.5,0.04)},font=\small},
legend style={at={(0.42,0.06)},anchor=south west, nodes={scale=0.8, transform shape},font=\small,}
]
\addplot[
color=black,
mark=square,
mark size=3,
]
coordinates { % Precision
#2
};
\addplot[
color=blue,
mark=diamond,
mark size=3,
]
coordinates { % Recall
#3
};
\legend{Precision, Recall}
\end{axis}
\end{tikzpicture}
}
}
\def\plotData{%
{3}/{(1,8.627451e+01)(2,6.274510e+01)(3,0.000000e+00)(4,0.000000e+00)}/{(1,1.000000e+02)(2,1.000000e+02)(3,0.000000e+00)(4,0.000000e+00)},
{4}/{(1,9.215686e+01)(2,7.843137e+01)(3,0.000000e+00)(4,0.000000e+00)}/{(1,1.000000e+02)(2,1.000000e+02)(3,0.000000e+00)(4,0.000000e+00)},
{5}/{(1,9.607843e+01)(2,8.627451e+01)(3,5.686275e+01)(4,0.000000e+00)}/{(1,1.000000e+02)(2,1.000000e+02)(3,1.000000e+02)(4,0.000000e+00)},
{6}/{(1,9.803922e+01)(2,9.019608e+01)(3,7.058824e+01)(4,0.000000e+00)}/{(1,1.000000e+02)(2,1.000000e+02)(3,1.000000e+02)(4,0.000000e+00)},
{7}/{(1,1.000000e+02)(2,9.215686e+01)(3,7.843137e+01)(4,5.294118e+01)}/{(1,9.622642e+01)(2,1.000000e+02)(3,1.000000e+02)(4,1.000000e+02)},
{8}/{(1,1.000000e+02)(2,9.607843e+01)(3,8.627451e+01)(4,5.882353e+01)}/{(1,9.107143e+01)(2,1.000000e+02)(3,1.000000e+02)(4,1.000000e+02)},
{9}/{(1,1.000000e+02)(2,9.607843e+01)(3,8.823529e+01)(4,7.058824e+01)}/{(1,8.095238e+01)(2,1.000000e+02)(3,1.000000e+02)(4,1.000000e+02)},
{10}/{(1,1.000000e+02)(2,9.803922e+01)(3,9.019608e+01)(4,7.843137e+01)}/{(1,7.391304e+01)(2,1.000000e+02)(3,1.000000e+02)(4,1.000000e+02)},
{11}/{(1,1.000000e+02)(2,9.803922e+01)(3,9.215686e+01)(4,8.627451e+01)}/{(1,6.144578e+01)(2,1.000000e+02)(3,1.000000e+02)(4,1.000000e+02)},
{12}/{(1,1.000000e+02)(2,1.000000e+02)(3,9.607843e+01)(4,8.823529e+01)}/{(1,5.543478e+01)(2,9.622642e+01)(3,1.000000e+02)(4,1.000000e+02)},
{13}/{(1,1.000000e+02)(2,1.000000e+02)(3,9.607843e+01)(4,8.823529e+01)}/{(1,4.636364e+01)(2,9.622642e+01)(3,1.000000e+02)(4,1.000000e+02)},
{14}/{(1,1.000000e+02)(2,1.000000e+02)(3,9.607843e+01)(4,9.019608e+01)}/{(1,4.146341e+01)(2,9.272727e+01)(3,1.000000e+02)(4,1.000000e+02)}}
\begin{document}
\begin{figure}[p]
\centering
\foreach \el/\recall/\precision in \plotData
{%
\plotprh{\el}{\precision}{\recall}%
}%
\caption{Results}
\label{results}
\end{figure}
\end{document}
我收到以下错误:
! Package pgfplots Error: Sorry, I could not read the plot coordinates near '(1
,1.000000e+02)(2,1.000000e+02)(3,0.000000e+00)(4,0.000000e+00) '. Please check
for format mistakes..
See the pgfplots package documentation for explanation.
Type H <return> for immediate help.
答案1
通常您应该卸载旧版本的 TeX Live 并安装 TeX Live 2016。
但为了快速修复,请在终端中输入以下命令:
wget http://mirrors.ctan.org/install/graphics/pgf/contrib/pgfplots.tds.zip
unzip pgfplots.tds.zip -d ~/texmf
rm pgfplots.tds.zip
并且你的 MWE 将会编译。