Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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}
share|improve this answer
    
I missed the part in the manual that says that indexing starts at zero. Thanks for that! The data plots well for the MWE with only one problem left to solve: the width of the bars makes them overlap with each other. However, that's another question. I'll see what the manual has to say about that. Thanks! –  Ricardo Oct 31 '12 at 14:57
1  
@Ricardo: Glad it helps! If you use ybar interval, the bars won't overlap. –  Jake Oct 31 '12 at 15:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.