pgfplot 未定义控制序列-(当使用带有 BOM 的 utf-8 文件时)

pgfplot 未定义控制序列-(当使用带有 BOM 的 utf-8 文件时)

我在这里得到了未定义的控制序列:但代码和 csv 文件看起来没问题。(这在某些时候有效)。有什么想法吗?

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{color}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplotstable}
\usepackage{longtable}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\usetikzlibrary{fillbetween,shapes,positioning,arrows,calc}
\begin{document}





% Preamble: \pgfplotsset{width=10cm,compat=1.12}
\begin{tikzpicture}
\begin{axis}[
width = \linewidth,
date coordinates in=x,
date ZERO=2014-12-11,
stack plots=y,
area style,
enlarge x limits=false,
xticklabel style={
    rotate=90,
    anchor=near xticklabel,
},
% set the label style of the `xtick's
xticklabel=\month - \year,
]
\addplot table [x=isodate, y=width, col sep=comma] {measures.csv} \closedcycle;
\addplot table [x=isodate, y=height, col sep=comma] {measures.csv} \closedcycle;;
\end{axis}
\end{tikzpicture}
\end{document}

错误详细信息:

! Undefined control sequence.
\GenericError ...
#4 \errhelp \@err@ ...
l.2408 ...] {measures.csv} \closedcycle;
^^M

示例文件:measures.csv

date,isodate,temperature,width,height
11-Dec-14,2014-12-11,1,0,1
12-Jan-15,2015-01-22,3,0,2

答案1

pgfplot 不能很好地支持带有 BOM 编码的 UTF-8 文件。通常可以通过文件开头的 EF BB BF 字节来识别。

非常感谢@Mike 和@TorbjørnT 帮助识别问题。

相关内容