| Class | Array |
| In: |
lib/gnuplot.rb
|
| Parent: | Object |
# File lib/gnuplot.rb, line 228
228: def to_gplot
229: if ( self[0].kind_of? Array ) then
230: tmp = self[0].zip( *self[1..-1] )
231: tmp.collect { |a| a.join(" ") }.join("\n") + "\ne"
232: elsif ( self[0].kind_of? Numeric ) then
233: s = ""
234: self.length.times { |i| s << "#{self[i]}\n" }
235: s
236: else
237: self[0].zip( *self[1..-1] ).to_gplot
238: end
239: end
# File lib/gnuplot.rb, line 241
241: def to_gsplot
242: f = ""
243:
244: if ( self[0].kind_of? Array ) then
245: x = self[0]
246: y = self[1]
247: d = self[2]
248:
249: x.each_with_index do |xv, i|
250: y.each_with_index do |yv, j|
251: f << [ xv, yv, d[i][j] ].join(" ") << "\n"
252: end
253: # f << "\n"
254: end
255: elsif ( self[0].kind_of? Numeric ) then
256: self.length.times do |i| f << "#{self[i]}\n" end
257: else
258: self[0].zip( *self[1..-1] ).to_gsplot
259: end
260:
261: f
262: end