Class: Numo::Gnuplot::SPlotArray

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

Instance Method Summary collapse

Methods inherited from PlotData

array_shape, #data_format, #line_str

Constructor Details

#initialize(data) ⇒ SPlotArray

:nodoc: all



870
871
872
# File 'lib/numo/gnuplot.rb', line 870

def initialize(data)
  @data = data
end

Instance Method Details

#cmd_strObject



874
875
876
877
878
879
880
881
# File 'lib/numo/gnuplot.rb', line 874

def cmd_str
  if @text
    "'-' matrix"
  else
    s = @data.shape
    "'-' binary array=(#{s[1]},#{s[0]}) format='%float64'"
  end
end

#data_strObject



883
884
885
886
887
888
889
890
891
892
893
894
895
896
# File 'lib/numo/gnuplot.rb', line 883

def data_str
  if @text
    f = data_format
    s = ""
    a.each do |b|
      s << b.map{|e| f%e}.join(" ")+"\n"
    end
    s+"\ne"
  elsif defined? Numo::NArray
    Numo::DFloat.cast(@data).to_string
  else
    @data.to_a.flatten.pack("d*")
  end
end