gnuplot 2.2 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gnuplot.rb +29 -9
- metadata +54 -31
data/lib/gnuplot.rb
CHANGED
@@ -17,9 +17,23 @@ module Gnuplot
|
|
17
17
|
# Return the full path to the first match or nil if no match is found.
|
18
18
|
#
|
19
19
|
def Gnuplot.which ( bin )
|
20
|
+
if RUBY_PLATFORM =~ /mswin|mingw/
|
21
|
+
all = [bin, bin + '.exe']
|
22
|
+
else
|
23
|
+
all = [bin]
|
24
|
+
end
|
25
|
+
for exec in all
|
26
|
+
if which_helper(exec)
|
27
|
+
return which_helper(exec)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
return nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def Gnuplot.which_helper bin
|
20
34
|
return bin if File::executable? bin
|
21
35
|
|
22
|
-
path = ENV['PATH']
|
36
|
+
path = ENV['PATH']
|
23
37
|
path.split(File::PATH_SEPARATOR).each do |dir|
|
24
38
|
candidate = File::join dir, bin.strip
|
25
39
|
return candidate if File::executable? candidate
|
@@ -42,6 +56,7 @@ module Gnuplot
|
|
42
56
|
# Return the path to the gnuplot executable or nil if one cannot be found.
|
43
57
|
def Gnuplot.gnuplot( persist = true )
|
44
58
|
cmd = which( ENV['RB_GNUPLOT'] || 'gnuplot' )
|
59
|
+
raise 'gnuplot executable not found' unless cmd
|
45
60
|
cmd += " -persist" if persist
|
46
61
|
cmd
|
47
62
|
end
|
@@ -73,11 +88,13 @@ module Gnuplot
|
|
73
88
|
def initialize (io = nil, cmd = "plot")
|
74
89
|
@cmd = cmd
|
75
90
|
@sets = []
|
91
|
+
@arbitrary_lines = []
|
76
92
|
@data = []
|
77
93
|
yield self if block_given?
|
78
|
-
|
94
|
+
puts "writing this to gnuplot:\n" + to_gplot + "\n" if $VERBOSE
|
79
95
|
io << to_gplot if io
|
80
96
|
end
|
97
|
+
attr_accessor :arbitrary_lines
|
81
98
|
|
82
99
|
# Invoke the set method on the plot using the name of the invoked method
|
83
100
|
# as the set variable and any arguments that have been passed as the
|
@@ -96,7 +113,7 @@ module Gnuplot
|
|
96
113
|
# readable code.
|
97
114
|
|
98
115
|
def set ( var, value = "" )
|
99
|
-
value = "
|
116
|
+
value = "\"#{value}\"" if QUOTED.include? var unless value =~ /^'.*'$/
|
100
117
|
@sets << [ var, value ]
|
101
118
|
end
|
102
119
|
|
@@ -118,20 +135,20 @@ module Gnuplot
|
|
118
135
|
|
119
136
|
def to_gplot (io = "")
|
120
137
|
@sets.each { |var, val| io << "set #{var} #{val}\n" }
|
138
|
+
@arbitrary_lines.each{|line| io << line << "\n" }
|
121
139
|
|
122
140
|
if @data.size > 0 then
|
123
141
|
io << @cmd << " " << @data.collect { |e| e.plot_args }.join(", ")
|
124
142
|
io << "\n"
|
125
143
|
|
126
|
-
|
127
|
-
|
144
|
+
v = @data.collect { |ds| ds.to_gplot }
|
145
|
+
io << v.compact.join("e\n")
|
128
146
|
end
|
129
147
|
|
130
148
|
io
|
131
149
|
end
|
132
150
|
end
|
133
151
|
|
134
|
-
|
135
152
|
class SPlot < Plot
|
136
153
|
|
137
154
|
def initialize (io = nil, cmd = "splot")
|
@@ -157,7 +174,6 @@ module Gnuplot
|
|
157
174
|
end
|
158
175
|
|
159
176
|
|
160
|
-
|
161
177
|
# Container for a single dataset being displayed by gnuplot. Each object
|
162
178
|
# has a reference to the actual data being plotted as well as settings that
|
163
179
|
# control the "plot" command. The data object must support the to_gplot
|
@@ -174,10 +190,11 @@ module Gnuplot
|
|
174
190
|
# @todo Use the delegator to delegate to the data property.
|
175
191
|
|
176
192
|
class DataSet
|
177
|
-
attr_accessor :title, :with, :using, :data, :linewidth, :matrix
|
193
|
+
attr_accessor :title, :with, :using, :data, :linewidth, :matrix, :smooth, :axes
|
178
194
|
|
179
195
|
def initialize (data = nil)
|
180
196
|
@data = data
|
197
|
+
@title = @with = @using = @linewidth = @matrix = @smooth = @axes = nil # avoid warnings
|
181
198
|
yield self if block_given?
|
182
199
|
end
|
183
200
|
|
@@ -192,7 +209,9 @@ module Gnuplot
|
|
192
209
|
io << ( (@data.instance_of? String) ? @data : "'-'" )
|
193
210
|
|
194
211
|
io << " using #{@using}" if @using
|
195
|
-
|
212
|
+
|
213
|
+
io << " axes #{@axes}" if @axes
|
214
|
+
|
196
215
|
io << case @title
|
197
216
|
when /notitle/ then " notitle"
|
198
217
|
when nil then ""
|
@@ -201,6 +220,7 @@ module Gnuplot
|
|
201
220
|
|
202
221
|
io << " matrix" if @matrix
|
203
222
|
io << " with #{@with}" if @with
|
223
|
+
io << " smooth #{@smooth}" if @smooth
|
204
224
|
io << " linewidth #{@linewidth}" if @linewidth
|
205
225
|
io
|
206
226
|
end
|
metadata
CHANGED
@@ -1,39 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.11
|
3
|
-
specification_version: 1
|
4
2
|
name: gnuplot
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
-
|
11
|
-
|
12
|
-
homepage: http://rgplot.rubyforge.org
|
13
|
-
rubyforge_project: rgplot
|
14
|
-
description:
|
15
|
-
autorequire: gnuplot.rb
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: false
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
-
|
22
|
-
- ">"
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 0.0.0
|
25
|
-
version:
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 2
|
7
|
+
- 3
|
8
|
+
- 1
|
9
|
+
version: 2.3.1
|
26
10
|
platform: ruby
|
27
|
-
signing_key:
|
28
|
-
cert_chain:
|
29
11
|
authors:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
12
|
+
- see AUTHORS.txt
|
13
|
+
autorequire: gnuplot.rb
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-22 00:00:00 -06:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Utility library to aid in interacting with gnuplot
|
22
|
+
email: rogerpack2005@gmail.com
|
36
23
|
executables: []
|
24
|
+
|
37
25
|
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- lib/gnuplot.rb
|
31
|
+
has_rdoc: true
|
32
|
+
homepage: http://github.com/rdp/ruby_gnuplot/tree/master
|
33
|
+
licenses: []
|
34
|
+
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
38
54
|
requirements: []
|
39
|
-
|
55
|
+
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.3.6
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: Utility library to aid in interacting with gnuplot
|
61
|
+
test_files: []
|
62
|
+
|