Method: RedPlot::Plotter#format_data

Defined in:
lib/redplot.rb

#format_data(raw_data) ⇒ Object

format the data from the callback blocks to fit gnuplot several interface are possible

1) a plain Array
2) an array of arrays, in which case these arrays are taken as data columns
3) anything with an each method 
   the block send to each takes one or more Numerics and/or numbers hidden in string


141
142
143
144
145
146
147
148
149
150
151
# File 'lib/redplot.rb', line 141

def format_data( raw_data )
  if raw_data.is_a? Array 
    if raw_data[0].is_a? Array  
      raw_data.transpose.map!{ |one_row| one_row.join " "}
    else
      raw_data
    end     
  else
   [].tap{ |data| raw_data.each { |*vals| data << vals.join(" ") } } #not tested yet
  end.<< 'end'
end