lib/gnuplotrb/plot.rb
##
# Create new Plot object where given datasets will
# be inserted into dataset list before given position
# (position = 0 by default).
#
# @param position [Integer] position of dataset BEFORE which datasets will be placed.
#   0 by default.
# @param *datasets [ Sequence of Dataset or Array] datasets to insert
# @example
#   sinx = Plot.new('sin(x)')
#   sinx_and_cosx_with_expx = sinx.add(['cos(x)'], ['exp(x)'])
#
#   cosx_and_sinx = sinx << ['cos(x)']
#   # sinx IS NOT affected in both cases
Create new Plot object where given datasets will
be inserted into dataset list before given position
(position = 0 by default).
Create new Plot object where given datasets will be inserted into dataset list before given position ( position = 0 by default ) .
def add_datasets(*datasets)
      datasets.map! { |ds| ds.is_a?(Numeric) ? ds : dataset_from_any(ds) }
      datasets.unshift(0) unless datasets[0].is_a?(Numeric)
      self.class.new(@datasets.insert(*datasets), @options)
    end
def add_datasets ( * datasets ) datasets . map! { | ds | ds . is_a? ( Numeric ) ? ds : dataset_from_any ( ds ) } datasets . unshift ( 0 ) unless datasets [ 0 ] . is_a? ( Numeric ) self . class . new ( @datasets . insert ( * datasets ) , @options ) end
Create new Plot object where given datasets will
be inserted into dataset list before given position
(position = 0 by default).
Create new Plot object where given datasets will be inserted into dataset list before given position ( position = 0 by default ) .
# first element is position where to add datasets
datasets
<not_specific>
position
<not_specific>
position of dataset BEFORE which datasets will be placed. 0 by default.
position of dataset BEFORE which datasets will be placed . 0 by default .
*datasets
<not_specific>
datasets to insert
datasets to insert
example
sinx = Plot.new('sin(x)') sinx_and_cosx_with_expx = sinx.add(['cos(x)'], ['exp(x)']) cosx_and_sinx = sinx << ['cos(x)'] # sinx IS NOT affected in both cases
sinx = Plot . new ( ' sin ( x ) ' ) sinx_and_cosx_with_expx = sinx . add ( [ ' cos ( x ) ' ] [ ' exp ( x ) ' ] ) cosx_and_sinx = sinx << [ ' cos ( x ) ' ] # sinx IS NOT affected in both cases