Graph
Use a FormulaGraph to plot a formula with Plot. Make sure to set the formula attribute as it is mendatory.
This method allows to read and set the formula. It expects a String.
The formula will be used by Gnuplot to generate the function values. All functions predefined by Gnuplot can be used. For more information, take a look at the Gnuplot manual. Please make sure to pass valid Gnuplot commands.
Example:
formulargraph_object.formula = "sin(x)"
The constructor accepts a Hash containing the single attributes. So Example 1 and 2 are both equivalent code.
Example 1
formulagraph_object = FormulaGraph.new formulagraph_object.formula = "x**2"
Example 2
formulagraph_object = FormulaGraph.new( formula: "x**2" )
# File gnuplot.rb, line 267 def initialize options options.each do |attr,value| attr = ("@" + attr.to_s) instance_variable_set attr, value end end
This method retuns the String containing the gnuplot code. It gets used along with Plot#to_gnuplot.
# File gnuplot.rb, line 277 def to_gnuplot str = "" s = instance_variable_not_empty?( "@formula" ) or raise "formula wasn't set." str += s + " " if instance_variable_not_empty? "@notitle" str += "notitle " else s = instance_variable_not_empty? "@title" str += "title \"#{s}\" " if s end s = instance_variable_not_empty? "@style" str += s if s str end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.