plotrobber 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/plotrobber/version.rb +1 -1
- data/lib/plotrobber.rb +15 -5
- metadata +2 -2
data/lib/plotrobber/version.rb
CHANGED
data/lib/plotrobber.rb
CHANGED
@@ -10,9 +10,9 @@ def plotting(&blk)
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
def plot(
|
13
|
+
def plot(filename=nil, &blk)
|
14
14
|
Gnuplot::Plot.new(@@gp) do |p|
|
15
|
-
p.
|
15
|
+
p.magic_terminal(filename) if filename
|
16
16
|
p.instance_exec(p, &blk)
|
17
17
|
end
|
18
18
|
end
|
@@ -25,7 +25,7 @@ class Gnuplot::Plot
|
|
25
25
|
def store(data)
|
26
26
|
(@store ||= {})[data] ||= begin
|
27
27
|
file = Tempfile.new(['plotrobber.','.dat'])
|
28
|
-
file.write data.map{|x|x.join("\t")}.join("\n")
|
28
|
+
file.write Array(data).map{|x|x.join("\t")}.join("\n")
|
29
29
|
file.write "\n"
|
30
30
|
file.rewind
|
31
31
|
|
@@ -33,6 +33,15 @@ class Gnuplot::Plot
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
def magic_terminal(name)
|
37
|
+
newest_change = caller.map {|c| File.mtime(c[/.*\.rb:/][0..-2]) }.max
|
38
|
+
|
39
|
+
unless ENV.key? 'STAGE'
|
40
|
+
terminal File.extname(name)[1..-1]
|
41
|
+
output name
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
36
45
|
def source_name(what)
|
37
46
|
name = case what
|
38
47
|
when String then what
|
@@ -41,7 +50,7 @@ class Gnuplot::Plot
|
|
41
50
|
else what.to_s
|
42
51
|
end
|
43
52
|
|
44
|
-
|
53
|
+
if !name.start_with?("'") and File.exists?(name)
|
45
54
|
name = "'#{name}'"
|
46
55
|
end
|
47
56
|
|
@@ -60,6 +69,7 @@ class Gnuplot::Plot
|
|
60
69
|
show name, options
|
61
70
|
end
|
62
71
|
|
72
|
+
|
63
73
|
def fit(what, using, use_b = true)
|
64
74
|
name = source_name what
|
65
75
|
|
@@ -70,7 +80,7 @@ class Gnuplot::Plot
|
|
70
80
|
using_str = using.join(':')
|
71
81
|
via_str = use_b ? "#{m}, #{b}" : m
|
72
82
|
|
73
|
-
please '%s(x) = %s*x + %s' % [f, m, use_b ? b : 0]
|
83
|
+
please '%s(x) = %s*x + %s + 1e-9' % [f, m, use_b ? b : 0]
|
74
84
|
please 'fit %s(x) %s using %s via %s' % [f, name, using_str, via_str]
|
75
85
|
|
76
86
|
"#{f}(x)"
|
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.4
|
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-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gnuplot
|