You are not logged in.
Hello people,
I have data of the form
2017-01-15 17:23:38 2.12
2017-01-15 17:27:14 13.30
2017-01-15 17:31:49 10.49
2017-01-15 17:31:49 7.82
2017-01-15 18:22:56 1.64in a file and I'm looking for a convenient way to visualize the values in the third column over the timeline including the time in the middle column.
What is the best tool to archieve this?
Offline
There are any number of tools. LOffice has a spreadsheet program that would do this much like excel would. Gnuplot could almost certainly do it. I'd use R or Sweave (R + LaTeX), most likely with the tikz graphics device output.
If you don't care too much about the x-axis labels, something as simple as the following R code would work:
d = read.table("/path/to/file")
plot(d$V3, type="l")Note "V3" is the default column name assigned to the 3rd data column when no names are provided in the file or to the read.table function.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thank you for the example.
I saw all the examples regarding R, but it’s something completly different to have something minimal to build on.
Offline
That is indeed a *very* minimal example. You can do a lot to tweak plots in R, feel free to ask if there are specific needs that you're not sure how to address.
I will admit that getting address+timestamp x-axis labels is not trivial. It's not really hard, but just not trivial as R would count those strings as factors by default which would result in a boxplot instead of a line plot. I make plots of project enrollment over time with both daily enrollment and a running total with separate left and right y axes, with nice labels, coloring, vertical bars dividing months, etc. That is a much more invovled script, but very doable in R once you learn a bit of how it works.
If you just want to get a feel for the "shape" of the data, the above minimal example may be sufficent. But if you want to present this to others, you'll certainly want to add some polish.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
gnuplot -p -e 'set xdata time; set timefmt "%Y-%m-%d %H:%M:%S"; plot "/dev/stdin" using 1:3 t "time" ' < test.dat
Edit: Figures, whilst I'm off figuring it out, Trilby gets it done ![]()
Last edited by ewaller (2017-01-15 18:42:42)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
The gnuplot solution has a couple of clear advantages. First I neglected the fact that the input might not be in sorted order, and second, my simple approach discards the x axis scale as it just treats the third column as a series of data.
I don't - off the top of my head - know the R function for reading time data but I'm sure there is one (format looks promising, but my first naive attempt didn't work as I expected) but basically you'd just modify the second line of R cod to be more like:
plot(d$V3~strtodate(paste(d$V1,d$V2)), type="l")the strtodate is a placeholder for a function that takes a string with a date and converts it into something more usable as a scale (a epoch-time timestamp for example).
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline