Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/gnuplot.rb
Instance Method Summary collapse
Instance Method Details
#to_gplot ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/gnuplot.rb', line 246 def to_gplot if ( self[0].kind_of? Array ) then tmp = self[0].zip( *self[1..-1] ) tmp.collect { |a| a.join(" ") }.join("\n") + "\ne" elsif ( self[0].kind_of? Numeric ) then s = "" self.length.times { |i| s << "#{self[i]}\n" } s else self[0].zip( *self[1..-1] ).to_gplot end end |
#to_gsplot ⇒ Object
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/gnuplot.rb', line 259 def to_gsplot f = "" if ( self[0].kind_of? Array ) then x = self[0] y = self[1] d = self[2] x.each_with_index do |xv, i| y.each_with_index do |yv, j| f << [ xv, yv, d[i][j] ].join(" ") << "\n" end # f << "\n" end elsif ( self[0].kind_of? Numeric ) then self.length.times do |i| f << "#{self[i]}\n" end else self[0].zip( *self[1..-1] ).to_gsplot end f end |