dcav-stats/plot.rb
Christoffer Müller Madsen e5dac03c61 updated xrange
2017-01-26 16:08:01 +01:00

57 lines
1.3 KiB
Ruby

# coding: utf-8
users = ["christoffermadsen","jmaa","jacob","alexander"]
colors = {}
users.each do |user|
colors[user] = "%06x" % (rand * 0xffffff)
end
log_dir = "./log/"
plotstring = %Q[set terminal 'svg' size 800,400 fname 'Verdana, Helvetica, Arial, sans-serif' \
fsize '14' rounded dashed
set key top left outside
set style line 1 lt 1 lw 2 pt 7 ps 0.4
set xlabel "Time"
set xdata time
set timefmt "%s"
set format x "%m/%d"
set xtics 60*60*24
set xrange [1485275000:]
set mxtics 2
set grid ytics mytics xtics mxtics
set title "Screenshot count"
set output "/home/christoffermadsen/public_html/img/screenshot_count.svg"
set ylabel "Count"
set yrange [0:]
set ytics 100
set mytics 2
plot ]
users.each do |user|
plotstring += %Q["log/#{user}.log" using 1:2 with lines ls 1 lc rgb '##{colors[user]}' t "#{user}", \\\n]
end
plotstring += %Q[
set title "Screenshot size"
set output "/home/christoffermadsen/public_html/img/screenshot_size.svg"
set ylabel "Size (MB)"
set yrange [0:100]
set ytics 10
set mytics 1
plot ]
users.each do |user|
colour = "%06x" % (rand * 0xffffff)
plotstring += %Q["log/#{user}.log" using 1:($3/10**6) with lines ls 1 lc rgb '##{colors[user]}' t "#{user}", \\\n]
end
output = File.open("plotscript","w")
output << plotstring
output.close
`gnuplot plotscript`