ruby-plot 0.6.0 → 0.6.1
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/VERSION +1 -1
- data/lib/plot_box.rb +17 -1
- data/lib/plot_lines.rb +7 -2
- data/lib/plot_points.rb +20 -16
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.1
|
data/lib/plot_box.rb
CHANGED
@@ -4,12 +4,14 @@ module RubyPlot
|
|
4
4
|
|
5
5
|
def self.box_plot(path, title, y_lable, names, values)
|
6
6
|
|
7
|
+
check_box_plot_available
|
8
|
+
|
7
9
|
LOGGER.debug "plot box -- names "+names.inspect
|
8
10
|
LOGGER.debug "plot box -- values "+values.inspect
|
9
11
|
|
10
12
|
# STDOUT.sync = true
|
11
13
|
raise if names.length != values.length
|
12
|
-
gnuplot = '
|
14
|
+
gnuplot = 'gnuplot'
|
13
15
|
|
14
16
|
tmp_datasets = []
|
15
17
|
tmp_file = Tempfile.new("data.dat")
|
@@ -90,6 +92,20 @@ EOF
|
|
90
92
|
|
91
93
|
tmp_datasets.each{|f| f.delete}
|
92
94
|
end
|
95
|
+
|
96
|
+
def self.check_box_plot_available
|
97
|
+
IO.popen('gnuplot --version') do |f|
|
98
|
+
while line = f.gets
|
99
|
+
if line =~ /^gnuplot ([0-9])+\.([0-9]+)/
|
100
|
+
major = Regexp.last_match(1).to_i
|
101
|
+
minor = Regexp.last_match(2).to_i
|
102
|
+
return true unless ((major==4 and minor<5) or major<4)
|
103
|
+
raise "gnuplot version < 4.5 ("+line.chomp+")"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
raise "could not parse gnuplot version"
|
108
|
+
end
|
93
109
|
|
94
110
|
def self.test_plot_box
|
95
111
|
# regression_point_plot("/tmp/regression.png" , "name of title", "x-values", "y-values", ["this-one-has-a-very-very-very-long-name", "test" ],
|
data/lib/plot_lines.rb
CHANGED
@@ -23,7 +23,8 @@ module RubyPlot
|
|
23
23
|
|
24
24
|
# gnuplot check
|
25
25
|
gnuplot=`which gnuplot | grep -o gnuplot`
|
26
|
-
|
26
|
+
#puts gnuplot
|
27
|
+
unless gnuplot =~ /gnuplot/
|
27
28
|
raise "Please install gnuplot.\n"+
|
28
29
|
"sudo apt-get install gnuplot"
|
29
30
|
end
|
@@ -99,7 +100,11 @@ module RubyPlot
|
|
99
100
|
output_plt_arr.push "set yrange [0:100]"
|
100
101
|
output_plt_arr.push "set grid lw 0.5"
|
101
102
|
output_plt_arr.push "set title \"#{title}\""
|
102
|
-
|
103
|
+
if plot_data.size>10
|
104
|
+
output_plt_arr.push "set nokey"
|
105
|
+
else
|
106
|
+
output_plt_arr.push "set key below"
|
107
|
+
end
|
103
108
|
#output_plt_arr.push "set key invert reverse Left outside"
|
104
109
|
output_plt_arr.push "set xlabel \"#{x_lable}\""
|
105
110
|
output_plt_arr.push "set ylabel \"#{y_lable}\""
|
data/lib/plot_points.rb
CHANGED
@@ -192,7 +192,11 @@ module RubyPlot
|
|
192
192
|
|
193
193
|
output_plt_arr.push "set grid lw 0.5"
|
194
194
|
output_plt_arr.push "set title \"#{title}\""
|
195
|
-
|
195
|
+
if names.size>10
|
196
|
+
output_plt_arr.push "set nokey"
|
197
|
+
else
|
198
|
+
output_plt_arr.push "set key below"
|
199
|
+
end
|
196
200
|
output_plt_arr.push "set xlabel \"#{x_lable}\""
|
197
201
|
output_plt_arr.push "set ylabel \"#{y_lable}\""
|
198
202
|
|
@@ -261,25 +265,25 @@ module RubyPlot
|
|
261
265
|
end
|
262
266
|
|
263
267
|
def self.test_plot_points
|
264
|
-
|
265
|
-
|
266
|
-
|
268
|
+
regression_point_plot("/tmp/regression.png" , "name of title", "x-values", "y-values", ["this-one-has-a-very-very-very-long-name", "test" ],
|
269
|
+
[[0.20,0.60,0.80,0.20,1.0,0.001], [0.10,0.25,0.70,0.95,0.2,0.3434]],
|
270
|
+
[[0.15,0.50,0.90,0.2,9,0.5],[0.20,0.40,0.50,0.70,0.3,0.234589]])
|
267
271
|
# accuracy_confidence_plot("/tmp/accuracy-conf.png" , "name of title", "x-values", "y-values", ["test" ],
|
268
272
|
# [[0.9,0.5,0.3,0.1]],
|
269
273
|
# [[100,90,70,30]])
|
270
274
|
|
271
|
-
x = []
|
272
|
-
y = []
|
273
|
-
noise = 0
|
274
|
-
100.times do |i|
|
275
|
-
i += 1
|
276
|
-
noise += rand**2 * (rand<0.5 ? 1 : -1)
|
277
|
-
x << i
|
278
|
-
y << 1/i + noise
|
279
|
-
end
|
280
|
-
confidence_plot("/tmp/test-plot.svg" , "name of title", "x-values", "y-values", ["test"],
|
281
|
-
[x],
|
282
|
-
[y])
|
275
|
+
# x = []
|
276
|
+
# y = []
|
277
|
+
# noise = 0
|
278
|
+
# 100.times do |i|
|
279
|
+
# i += 1
|
280
|
+
# noise += rand**2 * (rand<0.5 ? 1 : -1)
|
281
|
+
# x << i
|
282
|
+
# y << 1/i + noise
|
283
|
+
# end
|
284
|
+
# confidence_plot("/tmp/test-plot.svg" , "name of title", "x-values", "y-values", ["test"],
|
285
|
+
# [x],
|
286
|
+
# [y])
|
283
287
|
end
|
284
288
|
|
285
289
|
private
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-plot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 1
|
10
|
+
version: 0.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Vorgrimmler
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2012-02-28 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|