Class: Numo::Gnuplot::PlotData
- Inherits:
-
Object
- Object
- Numo::Gnuplot::PlotData
- Defined in:
- lib/numo/gnuplot.rb
Direct Known Subclasses
Instance Method Summary collapse
- #cmd_str ⇒ Object
-
#data_format ⇒ Object
:nodoc: all.
- #data_str ⇒ Object
-
#initialize(*data) ⇒ PlotData
constructor
A new instance of PlotData.
Constructor Details
#initialize(*data) ⇒ PlotData
Returns a new instance of PlotData.
514 515 516 517 518 |
# File 'lib/numo/gnuplot.rb', line 514 def initialize(*data) @data = data.map{|a| a.flatten} @n = @data.map{|a| a.size}.min @text = false end |
Instance Method Details
#cmd_str ⇒ Object
520 521 522 523 524 525 526 |
# File 'lib/numo/gnuplot.rb', line 520 def cmd_str if @text "'-'" else "'-' binary record=#{@n} format='%float64'" end end |
#data_format ⇒ Object
:nodoc: all
510 511 512 |
# File 'lib/numo/gnuplot.rb', line 510 def data_format @data_format || DATA_FORMAT end |
#data_str ⇒ Object
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
# File 'lib/numo/gnuplot.rb', line 528 def data_str if @text f = ([data_format]*@data.size).join(" ")+"\n" s = "" @n.times{|i| s << f % @data.map{|a| a[i]}} s+"\ne" elsif defined? Numo::NArray m = @data.size x = Numo::DFloat.zeros(@n,m) m.times{|i| x[true,i] = @data[i][0...@n]} x.to_string else s = [] @n.times{|i| s.concat @data.map{|a| a[i]}} s.pack("d*") end end |