lib/gnuplotrb/multiplot.rb
##
# Create new updated Multiplot object
# where plot (Plot or Splot object) at *position* will
# be replaced with the new one created from it by updating.
# To update a plot you can pass some options for it or a
# block, that should take existing plot (with new options if
# you gave them) and return a plot too.
#
# Method yields new created Plot or Splot to allow you update it manually.
#
# @param position [Integer] position of plot which you need to update
#   (by default first plot is updated)
# @param options [Hash] options to set into updated plot
# @return [Multiplot] self
# @yieldparam plot [Plot, Splot] a new plot
# @yieldreturn [Plot, Splot] changed plot
# @example
#   mp = Multiplot.new(Plot.new('sin(x)'), Plot.new('cos(x)'), layout: [2,1])
#   updated_mp = mp.update_plot(title: 'Sin(x) and Exp(x)') { |sinx| sinx.add!('exp(x)') }
#   # mp IS NOT affected
Create new updated Multiplot object
where plot (Plot or Splot object) at *position* will
be replaced with the new one created from it by updating.
To update a plot you can pass some options for it or a
block, that should take existing plot (with new options if
you gave them) and return a plot too.

Method yields new created Plot or Splot to allow you update it manually.
Create new updated Multiplot object where plot ( Plot or Splot object ) at * position * will be replaced with the new one created from it by updating . To update a plot you can pass some options for it or a block that should take existing plot ( with new options if you gave them ) and return a plot too . Method yields new created Plot or Splot to allow you update it manually .
def update_plot(position = 0, **options)
      return self unless block_given? if options.empty?
      replacement = @plots[position].options(options)
      replacement = yield(replacement) if block_given?
      replace_plot(position, replacement)
    end
def update_plot ( position = 0 , ** options ) return self unless block_given? if options . empty? replacement = @plots [ position ] . options ( options ) replacement = yield ( replacement ) if block_given? replace_plot ( position , replacement ) end
Create new updated Multiplot object
where plot (Plot or Splot object) at *position* will
be replaced with the new one created from it by updating.
Create new updated Multiplot object where plot ( Plot or Splot object ) at * position * will be replaced with the new one created from it by updating .
None
Multiplot
None
Plot, Splot
position
position of plot which you need to update (by default first plot is updated)
position of plot which you need to update ( by default first plot is updated )
options
options to set into updated plot
options to set into updated plot
plot
<not_specific>
a new plot
a new plot
example
mp = Multiplot.new(Plot.new('sin(x)'), Plot.new('cos(x)'), layout: [2,1]) updated_mp = mp.update_plot(title: 'Sin(x) and Exp(x)') { |sinx| sinx.add!('exp(x)') } # mp IS NOT affected
mp = Multiplot . new ( Plot . new ( ' sin ( x ) ' ) Plot . new ( ' cos ( x ) ' ) layout : [ 2 1 ] ) updated_mp = mp . update_plot ( title : ' Sin ( x ) and Exp ( x ) ' ) { |sinx| sinx . add! ( ' exp ( x ) ' ) } # mp IS NOT affected