Class: Numo::Gnuplot::SPlotRecord

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

Instance Method Summary collapse

Methods inherited from PlotData

array_shape, #as_array, #data_format, #data_str, #line_str, quote_data

Constructor Details

#initialize(x, y, z) ⇒ SPlotRecord

:nodoc: all


934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
# File 'lib/numo/gnuplot.rb', line 934

def initialize(x,y,z)
  @text = false
  @data = [x,y,z].map{|a| a.respond_to?(:flatten) ? a.flatten : a}
  @n = @data.map{|a| a.size}.min
  shape = PlotData.array_shape(@data[2])
  if shape.size >= 2
    n = shape[1]*shape[0]
    if @n < n
      raise GnuplotError, "data size mismatch"
    end
    @n = n
    @record = "#{shape[1]},#{shape[0]}"
  else
    @record = "#{@n}"
  end
end

Instance Method Details

#cmd_strObject


951
952
953
954
955
956
957
# File 'lib/numo/gnuplot.rb', line 951

def cmd_str
  if @text
    "'-'"
  else
    "'-' binary record=(#{@record}) format='%float64' using 1:2:3"
  end
end