scbi_plot 0.0.4

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/History.txt ADDED
@@ -0,0 +1,7 @@
1
+ === 0.0.4 2011-05-31
2
+
3
+ Fixed vertical lines
4
+
5
+ === 0.0.1 2011-04-07
6
+
7
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,15 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/scbi_plot.rb
7
+ script/console
8
+ script/destroy
9
+ script/generate
10
+ test/test_helper.rb
11
+ test/test_scbi_plot.rb
12
+ lib/scbi_plot/plot.rb
13
+ lib/scbi_plot/histogram.rb
14
+ lib/scbi_plot/lines.rb
15
+ lib/scbi_plot.rb
data/PostInstall.txt ADDED
@@ -0,0 +1,7 @@
1
+
2
+ For more information on scbi_plot, see http://scbi_plot.rubyforge.org
3
+
4
+ NOTE: Change this information in PostInstall.txt
5
+ You can also delete it if you don't want it.
6
+
7
+
data/README.rdoc ADDED
@@ -0,0 +1,99 @@
1
+ = scbi_plot
2
+
3
+ * http://www.scbi.uma.es/downloads
4
+
5
+ == DESCRIPTION:
6
+
7
+ scbi_plot is a simplified wrapper to create plots with gnuplot.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Create histogram plots with numeric or string x axis
12
+ * Create line and related plots (linespoints, points, impulses, etc...)
13
+
14
+ == SYNOPSIS:
15
+
16
+ === Histogram plot:
17
+
18
+ # create Histogram
19
+ p=ScbiPlot::Histogram.new('with_string_axis.png','title')
20
+
21
+ # add x axis data
22
+ p.add_x(['a','b','c'])
23
+
24
+ # add y axis data
25
+ p.add_y([10,20,30])
26
+
27
+ # generate graph
28
+ p.do_graph
29
+
30
+ === Line plot:
31
+
32
+ # Create lines plot
33
+ p=ScbiPlot::Lines.new('lines.png','title')
34
+
35
+ # create some random data
36
+ x=[]
37
+ y1=[]
38
+ y2=[]
39
+ y3=[]
40
+
41
+ 10.times do |i|
42
+ x.push i*10
43
+ y1.push i+(rand*50).to_i
44
+ y2.push i+(rand*50).to_i
45
+ y3.push i+(rand*50).to_i
46
+ end
47
+
48
+
49
+ # add x data
50
+ p.add_x(x)
51
+
52
+ # add a series
53
+ p.add_series('serie0', y1)
54
+
55
+ # draw another series with points
56
+ p.add_series('serie1', y2, 'points')
57
+
58
+ # add a third series with impulses of width 4
59
+ p.add_series('serie2', y3,'impulses',4)
60
+
61
+ # add a vertical line at pos 5
62
+ p.add_vertical_line('label',5)
63
+
64
+ # create graph
65
+ p.do_graph
66
+
67
+ == REQUIREMENTS:
68
+
69
+ * gnuplot binary
70
+ * gnuplot gem
71
+
72
+ == INSTALL:
73
+
74
+ * gem install scbi_plot
75
+
76
+ == LICENSE:
77
+
78
+ (The MIT License)
79
+
80
+ Copyright (c) 2011 Dario Guerrero
81
+
82
+ Permission is hereby granted, free of charge, to any person obtaining
83
+ a copy of this software and associated documentation files (the
84
+ 'Software'), to deal in the Software without restriction, including
85
+ without limitation the rights to use, copy, modify, merge, publish,
86
+ distribute, sublicense, and/or sell copies of the Software, and to
87
+ permit persons to whom the Software is furnished to do so, subject to
88
+ the following conditions:
89
+
90
+ The above copyright notice and this permission notice shall be
91
+ included in all copies or substantial portions of the Software.
92
+
93
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
94
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
95
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
96
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
97
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
98
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
99
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/scbi_plot'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'scbi_plot' do
14
+ self.developer 'Dario Guerrero Fernandez', 'dariogf@gmail.com'
15
+ # self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
18
+ self.extra_deps = [['gnuplot','>= 2.3.0']]
19
+
20
+ end
21
+
22
+ require 'newgem/tasks'
23
+ Dir['tasks/**/*.rake'].each { |t| load t }
24
+
25
+ # TODO - want other tests/tasks run by default? Add them to the list
26
+ # remove_task :default
27
+ task :default => [:spec, :features, :redocs]
@@ -0,0 +1,128 @@
1
+ require 'gnuplot'
2
+
3
+ # = scbi_plot - Ploting utilities
4
+ #
5
+ # Plots a graph using gnuplot.
6
+ #
7
+ # =Usage:
8
+ # p=ScbiPlot::Histogram.new('few_strings.png','titulo')
9
+ #
10
+ # p.add_x(['a','b','c'])
11
+ # p.add_y([10,20,30])
12
+ #
13
+ # p.do_graph
14
+ #
15
+ # =Tips
16
+ # * scbi_plot can handle integer and string values in x row
17
+ # * If x and y are integer values, the graph is sorted by x (ascendent values from left to right)
18
+ # * When x contains strings:
19
+ # -if number of elements in x is greater than x_limit (by default 20), values are sorted in descendant order, and only @x_limit values are plotted
20
+ # -if number of elements is below x_limit, then values are shown as an histogram
21
+ module ScbiPlot
22
+
23
+ class Histogram < ScbiPlot::Plot
24
+
25
+
26
+ def initialize(file_name,title=nil)
27
+ super
28
+ @line_width=4
29
+ @show_leyend=false
30
+ end
31
+
32
+ def do_graph
33
+ setup_data
34
+ # $VERBOSE=false
35
+
36
+ Gnuplot.open do |gp|
37
+ # histogram
38
+ Gnuplot::Plot.new( gp ) do |plot|
39
+
40
+ if !title
41
+ title=file_name
42
+ end
43
+
44
+ plot.title "#{@title}"
45
+ plot.xlabel @x_label
46
+ plot.ylabel @y_label
47
+
48
+ if !@show_leyend
49
+ plot.set "key off" #leyend
50
+ end
51
+
52
+ # x values are integers
53
+ if !contains_strings?(@x)
54
+
55
+ plot.style "fill pattern 22 border -1"
56
+ plot.set "boxwidth 0.2" # Probably 3-5.
57
+
58
+ plot.data << Gnuplot::DataSet.new( [@x, @y] ) do |ds|
59
+ ds.with= " imp lw #{@line_width}"
60
+ end
61
+
62
+ else #graph with strings in X axis
63
+ # $VERBOSE=true
64
+ plot.xlabel ""
65
+
66
+ plot.set "style fill solid 1.00 border -1"
67
+ plot.set "style histogram clustered gap 1 title offset character 0, 0, 0"
68
+ plot.set "style data histogram"
69
+ plot.set "boxwidth 0.2 absolute"
70
+ if @x.count>4 then
71
+ plot.set "xtics offset 0,graph 0 rotate 90"
72
+ end
73
+
74
+ plot.data << Gnuplot::DataSet.new( [@x,@y] ) do |ds|
75
+ ds.using = "2:xticlabels(1)" #show the graph and use labels at x
76
+ end
77
+
78
+ end
79
+
80
+ if !file_name.nil?
81
+ plot.terminal "png size 800,600"
82
+ plot.output "#{@file_name}"
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+
89
+
90
+ # def setup_data
91
+ # if @x.length != @y.length
92
+ # raise "Variables x and y have different sizes"
93
+ #
94
+ # else
95
+ #
96
+ # hash=xy_to_hash(@x,@y)
97
+ # # puts hash
98
+ # # sort integer data
99
+ # if !contains_strings?(@x)
100
+ #
101
+ # @x.sort!
102
+ # @y=[]
103
+ #
104
+ # @x.each do |v|
105
+ # @y.push hash[v].to_i
106
+ # end
107
+ #
108
+ #
109
+ # else # there are strings in X
110
+ # @x=[]
111
+ # @y=[]
112
+ #
113
+ # # save quoted values
114
+ # hash.keys.each do |v|
115
+ # @x.push "\"#{v.gsub('\"','').gsub('\'','')}\""
116
+ # @y.push hash[v.to_s]
117
+ # end
118
+ #
119
+ # # check if there is a lot of string data
120
+ # check_data_limit
121
+ #
122
+ # end
123
+ # end
124
+ # end
125
+ #
126
+ #
127
+ end
128
+ end
@@ -0,0 +1,117 @@
1
+ require 'gnuplot'
2
+
3
+ # = scbi_plot - Ploting utilities
4
+ #
5
+ # Plots a graph using gnuplot.
6
+ #
7
+ # =Usage:
8
+ # p=ScbiPlot::Histogram.new('few_strings.png','titulo')
9
+ #
10
+ # p.add_x(['a','b','c'])
11
+ # p.add_y([10,20,30])
12
+ #
13
+ # p.do_graph
14
+ #
15
+ # =Tips
16
+ # * scbi_plot can handle integer and string values in x row
17
+ # * If x and y are integer values, the graph is sorted by x (ascendent values from left to right)
18
+ # * When x contains strings:
19
+ # -if number of elements in x is greater than x_limit (by default 20), values are sorted in descendant order, and only @x_limit values are plotted
20
+ # -if number of elements is below x_limit, then values are shown as an histogram
21
+ module ScbiPlot
22
+
23
+ class Lines < ScbiPlot::Plot
24
+
25
+
26
+ def initialize(file_name,title=nil)
27
+ super
28
+ @series=[]
29
+ @line_width=2
30
+ @show_leyend=true
31
+ @vertical_lines=[]
32
+
33
+
34
+
35
+ end
36
+
37
+ def add_series(title, y_data, graph_type ='lines',line_width=nil)
38
+ @series << {:title => title, :data=> y_data, :graph_type=>graph_type, :line_width=>(line_width || @line_width)}
39
+ end
40
+
41
+ def add_vertical_line(title,x_value)
42
+ @vertical_lines << {:title => title, :x_value=> x_value}
43
+ end
44
+
45
+ def do_graph
46
+ setup_data
47
+ # $VERBOSE=true
48
+
49
+ Gnuplot.open do |gp|
50
+ # histogram
51
+ Gnuplot::Plot.new( gp ) do |plot|
52
+
53
+ if !title
54
+ title=file_name
55
+ end
56
+
57
+ plot.title "#{@title}"
58
+ plot.xlabel @x_label
59
+ plot.ylabel @y_label
60
+ plot.xrange "[#{@x.min}:#{@x.max}]"
61
+ plot.x2range "[#{@x.min}:#{@x.max}]"
62
+ # plot.x2range "auto"
63
+
64
+ if !@show_leyend
65
+ plot.set "key off" #leyend
66
+ end
67
+
68
+ # x values are integers
69
+ if contains_strings?(@x)
70
+ raise "Line plots cannot have strings in x axis"
71
+ end
72
+
73
+ # plot.style "fill pattern 22 border -1"
74
+ # plot.set "boxwidth 0.2" # Probably 3-5.
75
+ if !@vertical_lines.empty?
76
+ x2ticks =[]
77
+ @vertical_lines.each do |v_line|
78
+
79
+ x2ticks << "'#{v_line[:title]} (#{v_line[:x_value]})' #{v_line[:x_value]}"
80
+ end
81
+
82
+ plot.set "x2tics (#{x2ticks.join(', ')})"
83
+ plot.set 'grid noxtics x2tics lt rgb "green"'
84
+ end
85
+
86
+ @series.each do |series|
87
+ plot.data << Gnuplot::DataSet.new( [@x, series[:data]] ) do |ds|
88
+
89
+ ds.with = series[:graph_type]
90
+ ds.linewidth = series[:line_width]
91
+ ds.title = series[:title]
92
+
93
+ end
94
+
95
+ end
96
+
97
+ if !file_name.nil?
98
+ plot.terminal "png size 800,600"
99
+ plot.output "#{@file_name}"
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+
106
+
107
+ def setup_data
108
+ @series.each do |series|
109
+ if @x.length != series[:data].length
110
+ raise "Variables x and y have different sizes in serie #{series[:name]}"
111
+ end
112
+ end
113
+ end
114
+
115
+
116
+ end
117
+ end
@@ -0,0 +1,220 @@
1
+ require 'gnuplot'
2
+
3
+ # = scbi_plot - Ploting utilities
4
+ #
5
+ # Plots an histogram using gnuplot.
6
+ #
7
+ # =Usage:
8
+ # p=Plot.new('few_strings.png','titulo')
9
+ #
10
+ # p.add_x(['a','b','c'])
11
+ # p.add_y([10,20,30])
12
+ #
13
+ # p.do_graph
14
+ #
15
+ # =Tips
16
+ # * scbi_plot can handle integer and string values in x row
17
+ # * If x and y are integer values, the graph is sorted by x (ascendent values from left to right)
18
+ # * When x contains strings:
19
+ # -if number of elements in x is greater than x_limit (by default 20), values are sorted in descendant order, and only @x_limit values are plotted
20
+ # -if number of elements is below x_limit, then values are shown as an histogram
21
+ module ScbiPlot
22
+
23
+ class Plot
24
+
25
+ attr_accessor :title,:file_name,:x_label,:y_label,:x_limit,:x, :y, :line_width
26
+
27
+ def initialize(file_name,title=nil)
28
+
29
+ @x=[]
30
+ @y=[]
31
+ @x_label='x'
32
+ @y_label='y'
33
+
34
+ @title=title
35
+ @file_name=file_name
36
+
37
+ if @title.nil?
38
+ @title=file_name
39
+ end
40
+
41
+ @x_limit=20
42
+ @line_width=1
43
+
44
+ end
45
+
46
+ def add_x(x)
47
+ @x=x
48
+ end
49
+
50
+ def add_y(y)
51
+ @y=y
52
+ end
53
+
54
+
55
+ def add_xy(data)
56
+ @x=[]
57
+ @y=[]
58
+
59
+ if data.is_a?(Array)
60
+
61
+ data.each do |e|
62
+ @x.push e[0]
63
+ @y.push e[1]
64
+ end
65
+
66
+ elsif data.is_a?(Hash)
67
+
68
+ data.each do |k,v|
69
+ @x.push k
70
+ @y.push v
71
+ end
72
+
73
+ end
74
+ end
75
+
76
+
77
+ # def do_graph
78
+ # setup_data
79
+ # $VERBOSE=false
80
+ #
81
+ # Gnuplot.open do |gp|
82
+ # # histogram
83
+ # Gnuplot::Plot.new( gp ) do |plot|
84
+ #
85
+ # if !title
86
+ # title=file_name
87
+ # end
88
+ #
89
+ # plot.title "#{@title}"
90
+ # plot.xlabel @x_label
91
+ # plot.ylabel @y_label
92
+ #
93
+ # if !@show_leyend
94
+ # plot.set "key off" #leyend
95
+ # end
96
+ #
97
+ # # x values are integers
98
+ # if !contains_strings?(@x)
99
+ # plot.style "fill pattern 22 border -1"
100
+ # plot.set "boxwidth 0.2" # Probably 3-5.
101
+ #
102
+ # plot.data << Gnuplot::DataSet.new( [@x, @y] ) do |ds|
103
+ # ds.with= " imp lw 4"
104
+ # end
105
+ #
106
+ # else #graph with strings in X axis
107
+ # plot.xlabel ""
108
+ #
109
+ # plot.set "style fill solid 1.00 border -1"
110
+ # plot.set "style histogram clustered gap 1 title offset character 0, 0, 0"
111
+ # plot.set "style data histogram"
112
+ # plot.set "boxwidth 0.2 absolute"
113
+ #
114
+ # if @x.count>4 then
115
+ # plot.set "xtics offset 0,graph 0 rotate 90"
116
+ # end
117
+ #
118
+ # plot.data << Gnuplot::DataSet.new( [@x,@y] ) do |ds|
119
+ # ds.using = "2:xticlabels(1)" #show the graph and use labels at x
120
+ # end
121
+ #
122
+ # end
123
+ #
124
+ # if !file_name.nil?
125
+ # plot.terminal "png size 800,600"
126
+ # plot.output "#{@file_name}"
127
+ # end
128
+ # end
129
+ # end
130
+ # end
131
+
132
+
133
+ def xy_to_hash(x,y)
134
+ h={}
135
+
136
+ x.each_with_index do |x1,i|
137
+ h[x1]=y[i]
138
+ end
139
+
140
+ return h
141
+
142
+ end
143
+
144
+ def check_data_limit
145
+ # if more than 20 strings, then keep greater ones
146
+ if @x.count>@x_limit
147
+ h = xy_to_hash(@x,@y)
148
+
149
+ @x=[]
150
+ @y=[]
151
+
152
+ @x_limit.times do
153
+ ma=h.max_by{|k,v| v}
154
+ if ma
155
+ @x.push ma[0]
156
+ @y.push ma[1]
157
+ h.delete(ma[0])
158
+ end
159
+ end
160
+
161
+ end
162
+
163
+ end
164
+
165
+ def setup_data
166
+ if @x.length != @y.length
167
+ raise "Variables x and y have different sizes"
168
+
169
+ else
170
+
171
+ hash=xy_to_hash(@x,@y)
172
+ # puts hash
173
+ # sort integer data
174
+ if !contains_strings?(@x)
175
+
176
+ @x.sort!
177
+ @y=[]
178
+
179
+ @x.each do |v|
180
+ @y.push hash[v].to_i
181
+ end
182
+
183
+
184
+ else # there are strings in X
185
+ @x=[]
186
+ @y=[]
187
+
188
+ # save quoted values
189
+ hash.keys.each do |v|
190
+ # @x.push "\"#{v.gsub('\"','').gsub('\'','')}\""
191
+ @x.push "#{v.gsub('\"','').gsub('\'','')}"
192
+ # puts
193
+ @y.push hash[v.to_s]
194
+ end
195
+
196
+ # check if there is a lot of string data
197
+ check_data_limit
198
+
199
+ end
200
+ end
201
+ end
202
+
203
+ def contains_strings?(x)
204
+ contains_strings=false
205
+
206
+ x.each do |v|
207
+ begin
208
+ r=Integer(v)
209
+ rescue
210
+ contains_strings=true
211
+ break
212
+ end
213
+ end
214
+
215
+ return contains_strings
216
+ end
217
+
218
+
219
+ end
220
+ end
data/lib/scbi_plot.rb ADDED
@@ -0,0 +1,11 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'scbi_plot/plot'
5
+ require 'scbi_plot/histogram'
6
+ require 'scbi_plot/lines'
7
+
8
+
9
+ module ScbiPlot
10
+ VERSION = '0.0.4'
11
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/scbi_plot.rb'}"
9
+ puts "Loading scbi_plot gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/scbi_plot'
@@ -0,0 +1,93 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ require 'scbi_plot/plot'
4
+
5
+ class TestScbiPlot < Test::Unit::TestCase
6
+
7
+ def setup
8
+
9
+ end
10
+
11
+ def test_few_strings
12
+ p=ScbiPlot::Histogram.new('few_strings.png','titulo')
13
+
14
+ p.add_x(['a','b','c'])
15
+ p.add_y([10,20,30])
16
+
17
+ p.do_graph
18
+
19
+ assert(File.exists?('few_strings.png'))
20
+ end
21
+
22
+ def test_lot_of_strings
23
+ p=ScbiPlot::Histogram.new('lot_of_strings.png','titulo')
24
+
25
+ p.add_x(('a'..'z').to_a)
26
+ p.add_y((1..p.x.length).to_a)
27
+
28
+ p.do_graph
29
+
30
+ assert(File.exists?('lot_of_strings.png'))
31
+ end
32
+
33
+ def test_histogram
34
+ p=ScbiPlot::Histogram.new('histogram.png','titulo')
35
+
36
+ x=[]
37
+ y=[]
38
+
39
+ 1000.times do |i|
40
+ x.push i
41
+ y.push i+(rand*50).to_i
42
+ end
43
+
44
+ p.add_x(x)
45
+ p.add_y(y)
46
+
47
+ p.do_graph
48
+
49
+ assert(File.exists?('histogram.png'))
50
+ end
51
+
52
+ def test_lines
53
+ p=ScbiPlot::Lines.new('lines.png','titulo')
54
+
55
+ x=[]
56
+ y=[]
57
+ y2=[]
58
+ y3=[]
59
+
60
+ 10.times do |i|
61
+ x.push i*10
62
+ y.push i+(rand*50).to_i
63
+ y2.push i+(rand*50).to_i
64
+ y3.push i+(rand*50).to_i
65
+ end
66
+
67
+ p.add_x(x)
68
+ # p.add_y(y)
69
+ p.add_series('serie0', y)
70
+ p.add_series('serie1', y2, 'points')
71
+ p.add_series('serie2', y3,'impulses',4)
72
+
73
+ p.add_vertical_line('pos',5)
74
+
75
+ p.do_graph
76
+
77
+ assert(File.exists?('lines.png'))
78
+ end
79
+
80
+
81
+
82
+ def test_sizes
83
+ p=ScbiPlot::Histogram.new('bad.png','titulo')
84
+
85
+ p.add_x([4,3])
86
+ p.add_y([10,20,30])
87
+
88
+ assert_raise( RuntimeError ) { p.do_graph }
89
+
90
+ assert(!File.exists?('bad.png'))
91
+
92
+ end
93
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scbi_plot
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.4
6
+ platform: ruby
7
+ authors:
8
+ - Dario Guerrero Fernandez
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-31 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: gnuplot
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: hoe
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 2.8.0
35
+ type: :development
36
+ version_requirements: *id002
37
+ description: scbi_plot is a simplified wrapper to create plots with gnuplot.
38
+ email:
39
+ - dariogf@gmail.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - History.txt
46
+ - Manifest.txt
47
+ - PostInstall.txt
48
+ files:
49
+ - History.txt
50
+ - Manifest.txt
51
+ - PostInstall.txt
52
+ - README.rdoc
53
+ - Rakefile
54
+ - lib/scbi_plot.rb
55
+ - script/console
56
+ - script/destroy
57
+ - script/generate
58
+ - test/test_helper.rb
59
+ - test/test_scbi_plot.rb
60
+ - lib/scbi_plot/plot.rb
61
+ - lib/scbi_plot/histogram.rb
62
+ - lib/scbi_plot/lines.rb
63
+ homepage: http://www.scbi.uma.es/downloads
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options:
68
+ - --main
69
+ - README.rdoc
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project: scbi_plot
87
+ rubygems_version: 1.7.2
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: scbi_plot is a simplified wrapper to create plots with gnuplot.
91
+ test_files:
92
+ - test/test_helper.rb
93
+ - test/test_scbi_plot.rb