## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Plotting time-series, white-space-separated data, UNIX time

Information and discussion about graphics, figures & tables in LaTeX documents.
rjh2805
Posts: 2
Joined: Sun Jul 27, 2014 12:11 pm

### Plotting time-series, white-space-separated data, UNIX time

Hi all,

I'm trying to generate a plot using pgfplots, based on a data file that looks as follows:

`1403085611	20905.2942897	93251.93728681403085911	19610.7392042	87720.72132891403086212	19784.2685653	80539.6569753...`

So I have a UNIX timestamp, followed some measurement values. As far as I understood, pgfplots only supports ISO-formatted date/time-strings, so I try to use [cmd]\addplot shell[/cmd], together with gawk, to convert the UNIX timestamp to an ISO-formatted date/time-string:

`\addplot[     color = red,     mark = none] shell {gawk '/^[0-9]/{print strftime("\%Y-\%m-\%d \%H:\%M:\%S",\$1), \$2/1000}' data/results.log};`

This yields the following results:

`2014-06-18 12:00:11 20.90532014-06-18 12:05:11 19.61072014-06-18 12:10:12 19.7843`

However, compilation fails now since pgfplots interprets the date and time columns as separate values. Of course, I could use awk to make the values comma-separated, like in:

`\addplot[     color = red,     mark = none] shell {gawk '/^[0-9]/{print strftime("\%Y-\%m-\%d \%H:\%M:\%S",\$1), ",", \$2/1000}' data/results.log};`

This yields the following results:

`2014-06-18 12:00:11 , 20.90532014-06-18 12:05:11 , 19.61072014-06-18 12:10:12 , 19.7843`

However, the problem with this approach is that [cmd]\addplot shell[/cmd] does not have a 'col sep=comma' option, in the same way as [cmd]\addplot table[/cmd] has it.

I know that I could use gnuplot, etc., but my goal is to keep it as simple as possible, only using pgfplots. Any suggestions on how I could get pgfplots to plot my time-series?
Last edited by rjh2805 on Tue Jul 29, 2014 7:40 am, edited 1 time in total.

Tags:

Stefan Kottwitz
Posts: 8705
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Welcome to the forum!

Also I like to use pgfplots. I rarely use gnuplot, just together with pgfplots for contour plots.

I think you could run gawk, sed or any other such tool to convert to csv and read it in as a table, via `\addplot table`, even if `\addplot shell` would be more elegant.

Stefan

rjh2805
Posts: 2
Joined: Sun Jul 27, 2014 12:11 pm
Hi Stefan,

Using [cmd]\addplot shell[/cmd] would definitely be most elegant. However, I have no clue how to process comma-separated data using that command. Any suggestions?