Method: GnuplotRB::Plot#update_dataset

Defined in:
lib/gnuplotrb/plot.rb

#update_dataset(position = 0, data: nil, **options) ⇒ Object

Create new Plot object where dataset at position will be replaced with the new one created from it by updating.

Examples:

updated_plot = plot.update_dataset(data: [x1,y1], title: 'After update')
# plot IS NOT affected (if dataset did not store data in a file)

Parameters:

  • position (Integer) (defaults to: 0)

    position of dataset which you need to update (by default first dataset is updated)

  • data (#to_gnuplot_points) (defaults to: nil)

    data to update dataset with

  • options (Hash)

    options to update dataset with, see Dataset top level doc



106
107
108
109
110
# File 'lib/gnuplotrb/plot.rb', line 106

def update_dataset(position = 0, data: nil, **options)
  old_ds = @datasets[position]
  new_ds = old_ds.update(data, options)
  new_ds.equal?(old_ds) ? self : replace_dataset(position, new_ds)
end