Using logs to make statistics, I have a large number of data which contains two columns, like this (dd-mm-aaaa hh-mm float)

27-04-2018 04:43    7.78269552
27-04-2018 04:44    7.901522832
27-04-2018 04:45    7.754261587
27-04-2018 04:46    7.823737353
27-04-2018 04:47    7.799246215
27-04-2018 04:48    7.739765084
27-04-2018 04:49    7.776174494
27-04-2018 04:50    7.71269577
27-04-2018 04:51    7.682809896
27-04-2018 04:52    7.66061104
27-04-2018 04:53    7.727415335
27-04-2018 04:54    7.679670753
27-04-2018 04:55    7.677914655

By trying to plot those datas, I've written this :

\documentclass[12pt, openany]{report}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgf}

\usetikzlibrary{arrows}
\usepgfplotslibrary{dateplot} 

\tikzset{every picture/.style={execute at begin picture={\shorthandoff{:;!?};}}}
\pgfplotsset{compat=1.16}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
date coordinates in=x,
xtick=data,
xticklabel=\day. \hour:\minute
]
\addplot table [mark=none] {data.txt};
\end{axis}
\end{tikzpicture}
\end{document}

I know that there are some packages or infos that may not be necessary on that code, but it's just a sample of my document, that I've cut. I can still separate my two columns with a coma, but still i get that message :

! Package PGF Math Error: Could not parse input '04:44' as a floating point number, sorry. The unreadable part was near ':44'..

See the PGF Math package documentation for explanation.
Type  H <return>  for immediate help.

Hope my problem is clear enough. I've already looked on many other questions which doesn't answer it.

Thank you !

up vote 2 down vote accepted

Because your columns are whitespace separated you have, as far as pgfplots is concerned, three columns in the data file, not two. If there is a tab between the two columns, you can try using

\addplot[mark=none] table[col sep=tab]  {data.txt};

Alternatively, use for example a comma instead, i.e.

27-04-2018 04:43,    7.78269552

and then use col sep=comma to inform pgfplots of the column separator:

\addplot[mark=none] table[col sep=comma]  {data.txt};

(Your [mark=none] was in the wrong place, it is an option that concerns the plotting, not the table reading.)

enter image description here

\documentclass[12pt, openany]{report}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{pgfplots} % loads tikz which loads pgf

\usetikzlibrary{arrows}
\usepgfplotslibrary{dateplot} 

\tikzset{every picture/.style={execute at begin picture={\shorthandoff{:;!?};}}}
\pgfplotsset{compat=1.16}


%%%%%%%% just for example %%%%%%%%%%%
% filecontents makes the example self-contained
\usepackage{filecontents}
\begin{filecontents*}{mydata.dat}
27-04-2018 04:43,    7.78269552
27-04-2018 04:44,    7.901522832
27-04-2018 04:45,    7.754261587
27-04-2018 04:46,    7.823737353
27-04-2018 04:47,    7.799246215
27-04-2018 04:48,    7.739765084
27-04-2018 04:49,    7.776174494
27-04-2018 04:50,    7.71269577
27-04-2018 04:51,    7.682809896
27-04-2018 04:52,    7.66061104
27-04-2018 04:53,    7.727415335
27-04-2018 04:54,    7.679670753
27-04-2018 04:55,    7.677914655
\end{filecontents*}
%%%%%%%%%%---------%%%%%%%%%%%%%%%%

\begin{document}
\begin{tikzpicture}
\begin{axis}[
date coordinates in=x,
xtick=data,
xticklabel=\day. \hour:\minute,
xticklabel style={rotate=45,anchor=north east} % one option for making the ticklabels readable
]
\addplot[mark=none] table[col sep=comma]  {mydata.dat};
\end{axis}
\end{tikzpicture}
\end{document}
  • The data looks like it is tab delimited. Wouldn't it be better to say col sep=tab? so he don't has to change the datafile – sporc Jul 26 at 12:59
  • @sporc If that's the case, yes, that didn't even occur to me. (I never use tabs for anything.) The part of the file shown in the question has spaces though. – Torbjørn T. Jul 26 at 13:01
  • I think the spaces come from a tab delimiter when copying the file contents. 4 spaces = 1 tab – sporc Jul 26 at 13:04
  • @sporc Quite possibly, I don't know. Feel free to add answer yourself, if you don't want me to add it to mine. – Torbjørn T. Jul 26 at 13:08
  • I still got a problem of with unit : ! Illegal unit of measure (pt inserted). – Hugo Vernier-Lambert Jul 26 at 13:08

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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