lino
lino

Reputation: 85

Problem with gnuplot - timestamp data mapping to xrange

what i have:

csv data with timestamps in the first column, columns I want to plot selectively after that. Every data point ist roughly ten minutes apart. Data is for 24 hours. Everything else set up nicely, examples below

What i want:

Be able to map the time data formatted on the x-axis (xrange?). Like xtics every n hours, in a given format (like "%T, %A"). Best configurable per column I want to plot (thinking about multiplot).

Data:

1545389400,39,0,0,1,664,2493,31.7
1545390000,37,0,0,1,736,3093,32.5
1545391200,33,0,0,1,664,4293,32.6
1545392400,28,0,0,1,704,5493,31.3
1545393000,26,0,0,0,649,6093,30.8
1545393600,24,0,0,0,632,6693,30.5

Code:

set title "Battery Log"
set datafile separator ','
set key center bottom outside
set border lw 0.5 lc '#959595'
set terminal svg dynamic rounded mouse lw 1 background '#272822'
set grid ytics
set ytics nomirror in
set yrange [0:100]
set xtics nomirror
set xtics rotate
set xdata time
set timefmt "%s"
set format x "%T, %A"
plot 'stats.csv' \
    u 0:2 w l lc '#f92783' t columnheader, '' \
    u 0:8 w l lc '#a6e22a' t columnheader

screenshot

Upvotes: 0

Views: 342

Answers (1)

theozh
theozh

Reputation: 25704

what about this?

### set time xtics

N = 3  # every n-th hour

set samples 100
set xdata time 
set format x "%a, %H:%M"
set xtics rotate
set xtics N*3600

plot '+' u ($0*1200):(3*sin(x)+rand(0)) w lp pt 7 not
### end of code

which should give something like this, ticks every 3rd hour. Set your N depending on the column you want to plot.

enter image description here

Upvotes: 0

Related Questions