gnuplotr 0.2 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +2 -1
- data/lib/gnuplotr.rb +7 -1
- data/test.rb +1 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -38,7 +38,8 @@ Here's a quick example:
|
|
38
38
|
gp.set_title 'GNUPlotr example'
|
39
39
|
gp.set_xlabel 'x', :offset => 3, :font => "Times New Roman,26"
|
40
40
|
gp.set_ylabel "f(x)"
|
41
|
-
|
41
|
+
gp.set_xrange [0:50]
|
42
|
+
|
42
43
|
# issue plotting commands, either with named data series
|
43
44
|
gp.plot :parabola, "using 1:2 with points axes x1y1"
|
44
45
|
|
data/lib/gnuplotr.rb
CHANGED
@@ -32,7 +32,7 @@ end
|
|
32
32
|
class GNUPlotr
|
33
33
|
attr_accessor :gnuplot_path, :series, :record
|
34
34
|
def initialize(path=nil)
|
35
|
-
@gnuplot_path = (path ||
|
35
|
+
@gnuplot_path = (path || find_path)
|
36
36
|
raise RuntimeError, "Could not find #{@gnuplot_path}" unless File.exist? @gnuplot_path
|
37
37
|
@gnuplot, @stdout, @stderr = Open3.popen3(@gnuplot_path)
|
38
38
|
Thread.new { capture(@stdout) {|line| puts "> " + line } }
|
@@ -108,6 +108,8 @@ class GNUPlotr
|
|
108
108
|
t.to_s
|
109
109
|
when String
|
110
110
|
"'#{t}'"
|
111
|
+
when Range
|
112
|
+
"[#{t.begin}:#{t.end}]"
|
111
113
|
when Hash
|
112
114
|
r = ""
|
113
115
|
t.each {|k,v|
|
@@ -118,6 +120,10 @@ class GNUPlotr
|
|
118
120
|
t.to_s
|
119
121
|
end
|
120
122
|
end
|
123
|
+
|
124
|
+
def find_path
|
125
|
+
`which gnuplot`.chomp
|
126
|
+
end
|
121
127
|
end
|
122
128
|
|
123
129
|
|
data/test.rb
CHANGED
@@ -36,6 +36,7 @@ gp.set_grid
|
|
36
36
|
gp.set_title 'GNUPlotr example'
|
37
37
|
gp.set_xlabel 'x', :offset => 3, :font => "Times New Roman,26"
|
38
38
|
gp.set_ylabel "f(x)"
|
39
|
+
gp.set_xrange 0..50
|
39
40
|
|
40
41
|
# issue plotting commands, either with named data series
|
41
42
|
gp.plot :parabola, "using 1:2 with points axes x1y1"
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gnuplotr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: "0.
|
5
|
+
version: "0.4"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paolo Bosetti
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-03-05 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|