1

I have x-data as dates associated with float values; plotting them with pgfplots is as easy as

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}

\begin{axis}[
  date coordinates in=x,
  xticklabel style={rotate=90,anchor=near xticklabel},
  xticklabel=\year-\month-\day
]
\addplot table [red] {%
  2016-10-10 50
  2016-10-11 56
};
\end{axis}

\end{tikzpicture}
\end{document}

Now, I have dates plus times. Simply adding them to the table obviously results in a failed compilation

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}

\begin{axis}[
  date coordinates in=x,
  xticklabel style={rotate=90,anchor=near xticklabel},
  xticklabel=\year-\month-\day
]
\addplot table [red] {%
  2016-10-10 13:10 50
  2016-10-11 12:55 56
};
\end{axis}

\end{tikzpicture}
\end{document}
! Package PGF Math Error: Could not parse input '12:55' as a floating 
point number, sorry. The unreadable part was near ':55'..

How to specify times then?

Stefan Pinnow
  • 29,535

1 Answers1

1

I do not have any problems after adding a comma. Since you added the option red to the table: where did you add col sep=comma and header=false? At least this works:

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}

\begin{axis}[
  date coordinates in=x,
  xticklabel style={rotate=90,anchor=near xticklabel},
  xmin=2016-10-10 00:00,
  xmax=2016-10-12 00:00,
  xticklabel=\year-\month-\day
]
\addplot[only marks] table [col sep=comma,header=false] {%
  2016-10-10 13:10,50
  2016-10-11 12:55,56
};
\end{axis}

\end{tikzpicture}
\end{document}

enter image description here