我正在尝试使用从 WUnderground 气象站下载的数据绘制雨量图(每小时降水量与时间的关系,或数据文件中的第 10 列与第 1 列的关系)。时间列似乎已正确格式化为 ISO,但是,我收到以下错误:
错误:段落在 \pgfcalendar@datetojulian 完成之前结束。
--- TeX 说 --- \par l.39
--- 帮助 --- 命令参数中出现了一个不应包含空行的空行。您可能忘记了参数末尾的右括号。
我仔细检查了所有的牙套,它们似乎很平衡。也许我漏掉了什么。我该如何让它发挥作用?
这是我的 MWE:
\documentclass{standalone}
\usepackage{filecontents}
\begin{filecontents}{data.csv}
% There are 750 data rows in the file, so I only included the first three ones.
Time,TemperatureC,DewpointC,PressurehPa,WindDirection,WindDirectionDegrees,WindSpeedKMH,WindSpeedGustKMH,Humidity,HourlyPrecipMM,Conditions,Clouds,dailyrainMM,SoftwareType,DateUTC,
2012-10-23 00:00:00,24.8,21.9,1010.0,North,360,1.6,1.6,84,0.0,,,0.0,Wunderground v.1.15,2012-10-23 04:00:00,
2012-10-23 00:05:00,24.9,22.0,1010.0,NNW,348,1.6,4.8,84,0.0,,,0.0,Wunderground v.1.15,2012-10-23 04:05:00,
2012-10-23 00:10:00,24.8,21.9,1010.0,North,349,3.2,9.7,84,0.0,,,0.0,Wunderground v.1.15,2012-10-23 04:10:00,
% UNITS
\usepackage{siunitx}
\sisetup{%
per=slash, %
load=abbr, %
load=prefixed, %
group-separator = {,},%
range-phrase = {--}%
}
% PGFPLOTS and TABLES
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.3}
\usepgfplotslibrary{dateplot}
\usepackage{pgfplotstable}
\pgfplotstableset{col sep=comma}
\begin{document}
\pgfplotstableread{data.csv}\data
\begin{tikzpicture}
\begin{axis}[
date coordinates in=x,
xtick=data,
xticklabel style={rotate=90,anchor=near xticklabel},
xticklabel=\day. \hour:\minute,
date ZERO=2012-10-23,
xlabel=Time,
ylabel=Precipitation
]
\addplot+[ybar] table[x index=1,y=HourlyPrecipMM] {\data};
% x index is used because the header Time refuses to be recognized.
\end{axis}
\end{tikzpicture}
\end{document}
答案1
使用时的索引x index
从 开始,因此在这种情况下0
您需要使用。但是,对我来说工作正常。您可以检查以下内容是否适合您(我已经完成了 MWE 并放入了一些更令人兴奋的虚拟数据):x index=0
x=Time
\documentclass{standalone}
\usepackage{filecontents}
\begin{filecontents}{data.csv}
Time,TemperatureC,DewpointC,PressurehPa,WindDirection,WindDirectionDegrees,WindSpeedKMH,WindSpeedGustKMH,Humidity,HourlyPrecipMM,Conditions,Clouds,dailyrainMM,SoftwareType,DateUTC,
2012-10-23 00:00:00,24.8,21.9,1010.0,North,360,1.6,1.6,84,1.0,,,0.0,Wunderground v.1.15,2012-10-23 04:00:00,
2012-10-23 00:05:00,24.9,22.0,1010.0,NNW,348,1.6,4.8,84,0.4,,,0.0,Wunderground v.1.15,2012-10-23 04:05:00,
2012-10-23 00:10:00,24.8,21.9,1010.0,North,349,3.2,9.7,84,2.0,,,0.0,Wunderground v.1.15,2012-10-23 04:10:00,
\end{filecontents}
% UNITS
\usepackage{siunitx}
\sisetup{%
per=slash, %
load=abbr, %
load=prefixed, %
group-separator = {,},%
range-phrase = {--}%
}
% PGFPLOTS and TABLES
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.3}
\usepgfplotslibrary{dateplot}
\usepackage{pgfplotstable}
\pgfplotstableset{col sep=comma}
\begin{document}
\pgfplotstableread{data.csv}\data
\begin{tikzpicture}
\begin{axis}[
date coordinates in=x,
xtick=data,
xticklabel style={rotate=90,anchor=near xticklabel},
xticklabel=\day. \hour:\minute,
date ZERO=2012-10-23,
xlabel=Time,
ylabel=Precipitation,
ybar
]
\addplot table[x=Time,y=HourlyPrecipMM] {\data};
\end{axis}
\end{tikzpicture}
\end{document}