# PGFplot is not accepting date time file as input

I tried to read a file with time and date on x axis but it gives an error as "could not parse input "00:00:19" as floating point number"

I saved the excel file with "tab delimited" extension. I also put table/col sep as space.

\documentclass[conference]{IEEEtran}
\ifCLASSINFOpdf
\else
\fi
\hyphenation{op-tical net-works semi-conduc-tor}
\usepackage[pdftex]{graphics}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepgfplotslibrary{dateplot}
\usepgfplotslibrary{patchplots}
\pgfplotsset{compat=1.7}

\hyphenation{op-tical net-works semi-conduc-tor}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
xlabel=Time (hr:min),
height=5cm, width=8cm,
legend cell align=left, legend columns=-1, legend style={inner xsep=2pt, inner ysep=2pt,at={(0.35,0.1)},anchor=east,font=\tiny},
mark repeat={15},
label style={font=\small},
date coordinates in=x,
table/col sep=space,
% date ZERO=2010-01-1,
% xticklabel= \hour:\minute,
%    xticklabel style={anchor=near xticklabel},
ymin=-75, ymax=-55, ytick={-75,-70,-65,-60,-55},
]
\legend{Ch-15,Ch-17,Ch-26}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}


I could not find option to upload a text file here, so here is the sample

x   y
2018-05-18 00:00:19 -59
2018-05-18 00:01:01 -59
2018-05-18 00:01:31 -59
2018-05-18 00:02:17 -59
2018-05-18 00:02:40 -59
2018-05-18 00:03:17 -58
2018-05-18 00:03:32 -60
2018-05-18 00:04:03 -56
2018-05-18 00:04:25 -60
2018-05-18 00:04:46 -58
2018-05-18 00:05:44 -59
2018-05-18 00:06:08 -59
2018-05-18 00:06:41 -58
2018-05-18 00:07:09 -59
2018-05-18 00:07:20 -60
2018-05-18 00:08:05 -59
2018-05-18 00:08:31 -60
2018-05-18 00:09:06 -59
2018-05-18 00:09:25 -59
2018-05-18 00:10:00 -54
2018-05-18 00:10:42 -54

• isn't the data being split at spaces? so here you do not have x and y coords, but x, y and z coords. You'll probably need "..." or similar. – daleif Jun 7 '18 at 10:45

You're using a space as the column separator, and you have a space between yyyy-mm-dd and HH:MM:SS. So yyyy-mm-dd is read as the x-column, and HH:MM:SS as the y-column. Use something like

x,y
2018-05-18 00:00:19, -59
2018-05-18 00:01:01, -59


and

\addplot [...] table[col sep=comma] {...


Note by the way that the precision of the dateplot library is limited, so the seconds value is always ignored, and taken as zero. Hence,

2018-05-18 00:04:03 -56
2018-05-18 00:04:25 -60
2018-05-18 00:04:46 -58


is the same as

2018-05-18 00:04:00 -56
2018-05-18 00:04:00 -60
2018-05-18 00:04:00 -58


For that reason you can see in the image below that there are several cases of multiple markers at the same x-value. Depending on the amount and range of your data this may or may not be a problem. I note you have mark repeat=15, so I'm guessing it won't be much of a problem.

\documentclass[conference]{IEEEtran}
\usepgfplotslibrary{dateplot}
\pgfplotsset{compat=1.7}
\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
xlabel=Time (hr:min),
height=5cm, width=8cm,
legend cell align=left,
legend columns=-1,
legend style={
inner xsep=2pt,
inner ysep=2pt,
at={(0.35,0.1)},
anchor=east,
font=\tiny
},
%    mark repeat={15}, % commented for sake of example
label style={font=\small},
date coordinates in=x,
date ZERO=2018-05-18,
xticklabel= \hour:\minute,
%    xticklabel style={anchor=near xticklabel},
%    ymin=-75, ymax=-55, ytick={-75,-70,-65,-60,-55},  % commented for sake of example
table/col sep=comma % commma, not space
]

• @TayyabaLiaqat Did you put the comma in the actual cells in Excel? That's the wrong way to go about it, surely you can select the column delimiter when you save as CSV from Excel? If you use the exact format I show at the start of my answer, does it not work then? (With col sep=comma, of course.) – Torbjørn T. Jun 7 '18 at 11:29