[Tex/LaTex] \pgfcalendar@datetojulian error when plotting a time series using pgfplots

bar chartdateplotpgfplots

I am trying to plot a hyetogram (hourly precipitation vs time, or column 10 vs column 1 in my data file) with data downloaded from a WUnderground weather station. The time column seems to be properly ISO formatted, however, I am getting the following error:

ERROR: Paragraph ended before \pgfcalendar@datetojulian was complete.

— TeX said —
\par l.39

— HELP — A blank line occurred in a command argument that shouldn't contain one. You probably forgot the right brace at the end
of an argument.

I've double-checked all my braces and they seem to be balanced. Maybe I'm missing something. How can I get this to work?

Here's my 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}

Best Answer

The indexing when using x index starts at 0, so you'd want to use x index=0 in this case. However, x=Time works fine for me. Can you check whether the following works for you (I've completed the MWE and put a little bit more exciting dummy data in):

\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}
Related Question