Class: Gnuplot::DataSet

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

Overview

TODO:

Use the delegator to delegate to the data property.

Container for a single dataset being displayed by gnuplot. Each object has a reference to the actual data being plotted as well as settings that control the “plot” command. The data object must support the to_gplot command.

data The data that will be plotted. The only requirement is that the object understands the to_gplot method.

The following attributes correspond to their related string in the gnuplot command. See the gnuplot documentation for more information on this.

title, with

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) {|_self| ... } ⇒ DataSet

Returns a new instance of DataSet.

Yields:

  • (_self)

Yield Parameters:



200
201
202
203
204
# File 'lib/gnuplot.rb', line 200

def initialize (data = nil)
  @data = data
  @title = @with = @using = @linewidth = @matrix = @smooth = @axes = nil # avoid warnings
  yield self if block_given?
end

Instance Attribute Details

#axesObject

Returns the value of attribute axes.



198
199
200
# File 'lib/gnuplot.rb', line 198

def axes
  @axes
end

#dataObject

Returns the value of attribute data.



198
199
200
# File 'lib/gnuplot.rb', line 198

def data
  @data
end

#linewidthObject

Returns the value of attribute linewidth.



198
199
200
# File 'lib/gnuplot.rb', line 198

def linewidth
  @linewidth
end

#matrixObject

Returns the value of attribute matrix.



198
199
200
# File 'lib/gnuplot.rb', line 198

def matrix
  @matrix
end

#smoothObject

Returns the value of attribute smooth.



198
199
200
# File 'lib/gnuplot.rb', line 198

def smooth
  @smooth
end

#titleObject

Returns the value of attribute title.



198
199
200
# File 'lib/gnuplot.rb', line 198

def title
  @title
end

#usingObject

Returns the value of attribute using.



198
199
200
# File 'lib/gnuplot.rb', line 198

def using
  @using
end

#withObject

Returns the value of attribute with.



198
199
200
# File 'lib/gnuplot.rb', line 198

def with
  @with
end

Instance Method Details

#notitleObject



206
207
208
# File 'lib/gnuplot.rb', line 206

def notitle
  @title = "notitle"
end

#plot_args(io = "") ⇒ Object



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/gnuplot.rb', line 210

def plot_args (io = "")
  
  # Order of these is important or gnuplot barfs on 'em

  io << ( (@data.instance_of? String) ? @data : "'-'" )

  io << " using #{@using}" if @using
 
  io << " axes #{@axes}" if @axes
 
  io << case @title
        when /notitle/ then " notitle"
        when nil       then ""
        else " title '#{@title}'" 
        end

  io << " matrix" if @matrix
  io << " smooth #{@smooth}" if @smooth
  io << " with #{@with}" if @with
  io << " linewidth #{@linewidth}" if @linewidth
  io
end

#to_gplotObject



233
234
235
236
237
238
239
# File 'lib/gnuplot.rb', line 233

def to_gplot
  case @data
  when nil then nil
  when String then nil
  else @data.to_gplot
  end
end

#to_gsplotObject



241
242
243
244
245
246
247
# File 'lib/gnuplot.rb', line 241

def to_gsplot
  case @data
  when nil then nil
  when String then nil
  else @data.to_gsplot
  end
end