Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/gnuplot.rb
Instance Method Summary collapse
-
#to_gplot(io = '') ⇒ Object
Write GNUPLOT plot data to
io. -
#to_gsplot(io = '') ⇒ Object
Write GNUPLOT splot data to
io.
Instance Method Details
#to_gplot(io = '') ⇒ Object
Write GNUPLOT plot data to io.
282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/gnuplot.rb', line 282 def to_gplot(io = '') case x = self[0] when Array x.zip(*self[1..-1]).each { |a| io << a.join(' ') << "\n" } io << 'e' when Numeric then each { |i| io << "#{i}\n" } else x.zip(*self[1..-1]).to_gplot(io) end io end |
#to_gsplot(io = '') ⇒ Object
Write GNUPLOT splot data to io.
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/gnuplot.rb', line 295 def to_gsplot(io = '') case x = self[0] when Array y, d = values_at(1, 2) x.each_with_index { |xv, i| y.each_with_index { |yv, j| io << [xv, yv, d[i][j]].join(' ') << "\n" } } io when Numeric then each { |i| io << "#{i}\n" } else x.zip(*self[1..-1]).to_gsplot(io) end io end |