ruby-plot 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
@@ -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 = '/home/martin/software/gnuplot-dev/install/bin/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" ],
@@ -23,7 +23,8 @@ module RubyPlot
23
23
 
24
24
  # gnuplot check
25
25
  gnuplot=`which gnuplot | grep -o gnuplot`
26
- if gnuplot!="gnuplot\n"
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
- output_plt_arr.push "set key below"
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}\""
@@ -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
- output_plt_arr.push "set key below"
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
- # regression_point_plot("/tmp/regression.png" , "name of title", "x-values", "y-values", ["this-one-has-a-very-very-very-long-name", "test" ],
265
- # [[0.20,0.60,0.80,0.20,1.0,0.001], [0.10,0.25,0.70,0.95,0.2,0.3434]],
266
- # [[0.15,0.50,0.90,0.2,9,0.5],[0.20,0.40,0.50,0.70,0.3,0.234589]])
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: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
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: 2011-11-25 00:00:00 +01:00
19
+ date: 2012-02-28 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency