Class: Matrix

Inherits:
Object
  • Object
show all
Defined in:
lib/gnuplot.rb

Instance Method Summary collapse

Instance Method Details

#to_gplot(io = '', xgrid = nil, ygrid = nil) ⇒ Object

Write GNUPLOT plot data to io.



319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/gnuplot.rb', line 319

def to_gplot(io = '', xgrid = nil, ygrid = nil)
  xgrid ||= (0...column_size).to_a
  ygrid ||= (0...row_size).to_a

  ygrid.each_with_index { |y, j|
    xgrid.each_with_index { |x, i|
      z = self[j, i]
      io << "#{x} #{y} #{z}\n" if z
    }
  }

  io
end