ruby-plot 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/plot_lines.rb +25 -7
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.4.3
data/lib/plot_lines.rb CHANGED
@@ -8,11 +8,12 @@
8
8
 
9
9
  module RubyPlot
10
10
 
11
- def self.plot_lines(path, title, x_lable, y_lable, names, x_values, y_values, faint=nil)
11
+ def self.plot_lines(path, title, x_lable, y_lable, names, x_values, y_values, faint=nil, labels=nil)
12
12
 
13
- #LOGGER.debug names.inspect
14
- #LOGGER.debug x_values.inspect
15
- #LOGGER.debug y_values.inspect
13
+ LOGGER.debug "plot lines -- "+names.inspect
14
+ LOGGER.debug "plot lines -- "+x_values.inspect
15
+ LOGGER.debug "plot lines -- "+y_values.inspect
16
+ LOGGER.debug "plot lines -- "+labels.inspect
16
17
 
17
18
  data = []
18
19
  (0..x_values.size-1).each do |i|
@@ -116,7 +117,7 @@ module RubyPlot
116
117
 
117
118
  # x and y have equal scale
118
119
  output_plt_arr.push 'set size ratio -1'
119
-
120
+
120
121
  output_plt_arr.push "set xrange [0:100]"
121
122
  output_plt_arr.push "set yrange [0:100]"
122
123
  output_plt_arr.push "set grid lw 0.5"
@@ -131,6 +132,23 @@ module RubyPlot
131
132
  output_plt_arr.push ""
132
133
  output_plt_arr.push ""
133
134
  output_plt_arr.push "# Draws the plot and specifies its appearance ..."
135
+
136
+ if labels!=nil
137
+ type = 1
138
+ labels.each do |label|
139
+ if label!=nil
140
+ l = label[0]
141
+ x = label[1]
142
+ y = label[2]
143
+ puts l.to_s+" "+x.to_s+" "+y.to_s
144
+ #output_plt_arr.push "set label \"("+x.to_s+","+y.to_s+") "+l.to_s+"\" at first 25, first 40"
145
+ output_plt_arr.push "set label \""+l.to_s+"\" at first "+x.to_s+", first "+y.to_s+" front offset 1,-1 tc lt "+type.to_s
146
+ output_plt_arr.push "set arrow from "+(x+3).to_s+","+(y-3).to_s+" to "+(x+1).to_s+","+(y-1).to_s+" lt "+type.to_s
147
+ end
148
+ type += 1
149
+ end
150
+ end
151
+
134
152
  output_plt_arr.push "plot \\"#'random_0.dat' using 1:2 title 'random' with lines lw 1, \\"
135
153
  i = 0
136
154
  for i in 0..names.length-1
@@ -180,9 +198,9 @@ module RubyPlot
180
198
  end
181
199
 
182
200
  def self.test_plot_lines
183
- plot_lines("/tmp/result.svg" , "name of title", "x-values", "y-values", ["name", "test", "bla"], [[20,60,80], [10,25,70,95], [12,78,99]], [[15,50,90],[20,40,50,70],[34,89,89]],[true,false,true])
201
+ #plot_lines("/tmp/result.svg" , "name of title", "x-values", "y-values", ["name", "test", "bla"], [[20,60,80], [10,25,70,95], [12,78,99]], [[15,50,90],[20,40,50,70],[34,89,89]],[true,false,true])
184
202
 
185
- plot_lines("/tmp/result.png" , "name of title", "x-values", "y-values", ["name", "test", "bla"], [[20,60,80], [10,25,70,95], [12,78,99]], [[15,50,90],[20,40,50,70],[34,89,89]],[true,false,true])
203
+ plot_lines("/tmp/result.png" , "name of title", "x-values", "y-values", ["name", "test", "bla"], [[20,60,80], [10,25,70,95], [12,78,99]], [[15,50,90],[20,40,50,70],[34,89,89]],[true,false,true],[nil,["confidence",25,40]])
186
204
  end
187
205
 
188
206
  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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
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-05-17 00:00:00 +02:00
19
+ date: 2011-05-19 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency