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:



143
144
145
146
# File 'lib/gnuplot.rb', line 143

def initialize (data = nil)
  @data = data
  yield self if block_given?
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



141
142
143
# File 'lib/gnuplot.rb', line 141

def data
  @data
end

#linewidthObject

Returns the value of attribute linewidth.



141
142
143
# File 'lib/gnuplot.rb', line 141

def linewidth
  @linewidth
end

#matrixObject

Returns the value of attribute matrix.



141
142
143
# File 'lib/gnuplot.rb', line 141

def matrix
  @matrix
end

#titleObject

Returns the value of attribute title.



141
142
143
# File 'lib/gnuplot.rb', line 141

def title
  @title
end

#usingObject

Returns the value of attribute using.



141
142
143
# File 'lib/gnuplot.rb', line 141

def using
  @using
end

#withObject

Returns the value of attribute with.



141
142
143
# File 'lib/gnuplot.rb', line 141

def with
  @with
end

Instance Method Details

#notitleObject



148
149
150
# File 'lib/gnuplot.rb', line 148

def notitle
  @title = "notitle"
end

#plot_args(io = "") ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/gnuplot.rb', line 152

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 << case @title
        when /notitle/ then " notitle"
        when nil       then ""
        else " title '#{@title}'" 
        end

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

#to_gplotObject



172
173
174
175
176
177
178
# File 'lib/gnuplot.rb', line 172

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

#to_gsplotObject



180
181
182
183
184
185
186
# File 'lib/gnuplot.rb', line 180

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