当我尝试使用该命令绘制图形时\addplot[ ]table{ }
出现以下错误:
! File ended while scanning use of \pgfplots@addplotimpl@table@fromfile.
<inserted text>
\par
<*> "./plot 3.tex"
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.
! Emergency stop.
<*> "./plot 3.tex"
*** (job aborted, no legal \end found)
Here is how much of TeX's memory you used:
21773 strings out of 480790
587455 string characters out of 2897770
949245 words of memory out of 3000000
37477 multiletter control sequences out of 15000+200000
537874 words of font info for 42 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
74i,9n,127p,732b,1959s stack positions out of 5000i,500n,10000p,200000b,50000s
! ==> Fatal error occurred, no output PDF file produced!`enter code here`
你知道哪里出了问题吗?我附上了下面使用的代码,看看是否缺少了什么。这是我第一次使用它,唯一一次出现此错误是当我尝试从表格中绘图时(即使在导入 .txt .csv 文件时),除此之外,整个包运行正常。谢谢
\documentclass[12pt]{article}
%\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel={x},
ylabel={y}
]
\addplot[red, mark=o]table[x=x,y=y]{
x y
1.7 1.5
2.2 2
2.7 2.5
3.2 2.9
3.6 3.3
4.2 3.8
4.9 4.5
5.3 4.8
}
\end{axis}
\end{tikzpicture}
\end{document}
答案1
正如用户@Rmano 正确建议的那样,缺少;
。
\documentclass[12pt]{article}
%\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel={x},
ylabel={y}
]
\addplot[red, mark=o]table[x=x,y=y]
{
x y
1.7 1.5
2.2 2
2.7 2.5
3.2 2.9
3.6 3.3
4.2 3.8
4.9 4.5
5.3 4.8
}; % <---------------missing ; added
\end{axis}
\end{tikzpicture}
\end{document}