Paul G.
Paul G.

Reputation: 479

gnuplot event frequency over time

I have an aviary and collect timestamps via camera-motion-detection every time a bird enters or leave. Now I have a load of timestamps in the format:

2019-06-19-08:14:17
2019-06-19-08:16:59
2019-06-19-08:18:11
2019-06-19-08:20:44
2019-06-19-08:20:59
2019-06-19-08:25:33
2019-06-19-08:26:03
...

of more than 3 days and I want to visualize the "bird traffic" over the days to be able to say, "Oh, at 2 o'clock is a lot of bird traffic...".

What I tried so far is a pretty basic non-functional script:

set terminal pngcairo size 800,400 enhanced font 'Verdana,10' linewidth 1
set output 'birds.png'
set xdata time
set timefmt "%Y-%m-%d-%H:%M:%S"
set format x "%H:%M"
set xtics nomirror rotate by -45 font 'Verdana-Bold,10'
set ytics font 'Verdana-Bold,10'
set xrange ["2019-06-19-08:14:17":"2019-06-23-18:27:17"]

plot 'events.log'

I know it maybe has to do with "smooth freq" and binning the data somehow but I cant figure out how to do that. Any ideas?

Upvotes: 0

Views: 64

Answers (1)

Michael
Michael

Reputation: 5335

set xdata time
set timefmt "%Y-%m-%d-%H:%M:%S"
set format x "%H:%M"
bin_width=120
bin(t) = (t - (int(t) % bin_width))
set boxwidth 100
plot [] [0:3] 'events.log' u (bin(timecolumn(1, "%Y-%m-%d-%H:%M:%S"))):(1.0) smooth freq with boxes

enter image description here

(solution found here)

Upvotes: 1

Related Questions