plotrobber 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -0
- data/lib/plotrobber/version.rb +1 -1
- data/lib/plotrobber.rb +41 -3
- metadata +2 -2
data/README.md
CHANGED
data/lib/plotrobber/version.rb
CHANGED
data/lib/plotrobber.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'plotrobber/version'
|
2
2
|
|
3
3
|
require 'gnuplot'
|
4
|
+
require 'tempfile'
|
4
5
|
|
5
6
|
def plotting(&blk)
|
6
7
|
Gnuplot.open do |gp|
|
@@ -17,10 +18,47 @@ def plot(title = nil, &blk)
|
|
17
18
|
end
|
18
19
|
|
19
20
|
class Gnuplot::Plot
|
20
|
-
def
|
21
|
+
def please(s)
|
22
|
+
arbitrary_lines << s
|
23
|
+
end
|
24
|
+
|
25
|
+
def candlesticks(name, extra_opts = {})
|
26
|
+
with_opt = case extra_opts[:with]
|
27
|
+
when Hash, Array then 'candlesticks ' + extra_opts[:with].to_a.join(' ')
|
28
|
+
when String then 'candlesticks ' + extra_opts[:with]
|
29
|
+
else 'candlesticks'
|
30
|
+
end
|
31
|
+
|
32
|
+
options = {using: '1:3:2:6:5', with: with_opt}.merge(extra_opts)
|
33
|
+
|
34
|
+
show name, options
|
35
|
+
end
|
36
|
+
|
37
|
+
def show(name, *args)
|
38
|
+
if Array === name
|
39
|
+
file = Tempfile.new(['plotrobber.','.dat'])
|
40
|
+
file.write name.map{|x|x.join("\t")}.join("\n")
|
41
|
+
file.close
|
42
|
+
|
43
|
+
@files ||= []
|
44
|
+
@files << file
|
45
|
+
|
46
|
+
name = file.path
|
47
|
+
end
|
48
|
+
|
49
|
+
unless name.start_with? "'"
|
50
|
+
name = "'#{name}'"
|
51
|
+
end
|
52
|
+
|
21
53
|
self.data << Gnuplot::DataSet.new(name) do |ds|
|
22
|
-
for
|
23
|
-
|
54
|
+
for arg in args
|
55
|
+
if Hash === arg
|
56
|
+
for k, v in arg
|
57
|
+
ds.send("#{k}=", v)
|
58
|
+
end
|
59
|
+
else
|
60
|
+
ds.send arg.to_s
|
61
|
+
end
|
24
62
|
end
|
25
63
|
end
|
26
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plotrobber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gnuplot
|