Skip to content

Commit 2461320

Browse files
committed
add misc/bar misc/timefmt
1 parent 8c09f12 commit 2461320

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

misc/bar/bar.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'numo/gnuplot'
2+
3+
x = ['a','b','c','d']
4+
y = [10,20,40,30]
5+
6+
Numo.gnuplot do
7+
debug_on
8+
set boxwidth:0.5
9+
set style:[fill:'solid']
10+
plot x,y, using:[2,'xtic(1)'], with:'boxes'
11+
end
12+
13+
gets

misc/timefmt/test.dem

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# http://stackoverflow.com/questions/4515621/gnuplot-timefmt-issue
2+
3+
set xdata time
4+
set timefmt x '"%Y-%m-%d %H:%M:%S"'
5+
#set xrange ['"2010-08-28 02:44:55"':'"2010-12-19 16:46:55"']
6+
#set xrange ['"2010-08-28 02:44:55"':'"2010-08-30 16:46:55"']
7+
#set yrange [0:500]
8+
#set datafile separator "|"
9+
10+
plot '-' using 3:1 w lp
11+
3 Harpos "2010-08-28 02:44:55"
12+
5 Harpos "2010-08-29 02:09:19"
13+
4 Harpos "2010-08-29 02:22:25"
14+
26 Harpos "2010-08-30 03:01:09"
15+
e
16+
17+
pause mouse

misc/timefmt/timefmt.rb

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
require "numo/gnuplot"
2+
3+
data= <<EOL
4+
2016-07-19T23:47:53.432Z 33.2
5+
2016-07-19T23:41:59.558Z 33.1
6+
2016-07-19T23:36:06.183Z 32.9
7+
2016-07-19T23:30:09.101Z 32.7
8+
2016-07-19T23:24:15.936Z 32.6
9+
2016-07-19T23:18:19.082Z 32.4
10+
2016-07-19T23:12:20.944Z 32.4
11+
2016-07-19T23:06:28.191Z 32.3
12+
2016-07-19T23:00:35.459Z 31.6
13+
2016-07-19T22:54:33.798Z 31.2
14+
2016-07-19T22:48:31.436Z 30.7
15+
2016-07-19T22:42:27.744Z 30.1
16+
2016-07-19T22:36:30.776Z 29.7
17+
2016-07-19T22:30:32.814Z 29.4
18+
2016-07-19T22:24:38.774Z 28.8
19+
2016-07-19T22:18:38.911Z 28.5
20+
2016-07-19T22:12:45.805Z 28.2
21+
2016-07-19T22:06:39.124Z 27.7
22+
2016-07-19T22:00:39.920Z 27.1
23+
2016-07-19T21:54:42.007Z 26.5
24+
EOL
25+
26+
x,y = data.split(/\n/).map{|x| x.split}.transpose
27+
y.map!{|i| i.to_f}
28+
29+
Numo.gnuplot do
30+
debug_on
31+
set ylabel: 'Temperature degree'
32+
set xlabel: "Time (starting at #{x[0]})"
33+
set xdata: "time"
34+
set timefmt_x: "'\"%Y-%m-%dT%H:%M:%SZ\"'"
35+
set format_x: '%H:%M'
36+
set :style, :data, "lines"
37+
#set 'terminal postscript color eps enhanced font "Helvetica,13" size 16cm,8cm'
38+
#set "output 'temperature-pcb.ps'"
39+
40+
plot x,y,using:[1,2],with:"linespoints",lc_rgb:"black",lw:3,notitle:true
41+
end
42+
43+
gets

0 commit comments

Comments
 (0)