Class: RubyPost::LinePlot

Inherits:
AbstractPlot show all
Defined in:
lib/simpleplot.rb

Instance Attribute Summary

Attributes inherited from AbstractPlot

#x, #y

Attributes inherited from BaseDrawCommand

#drawable

Instance Method Summary collapse

Methods inherited from AbstractPlot

#xmax, #xmin, #ymax, #ymin

Methods inherited from BaseDrawCommand

#add_option, #color, #colour, #compile_options, #rotate, #scale, #set_drawable, #translate

Constructor Details

#initialize(x, y) ⇒ LinePlot

Intitalise with two arrays of the same size.



136
137
138
139
140
# File 'lib/simpleplot.rb', line 136

def initialize(x, y)
  super()
  @x = x
  @y = y
end

Instance Method Details

#compileObject



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

def compile
  @p = Path.new
  @x.each_index{ |i| @p.add_pair(Pair.new(@x[i].cm, @y[i].cm)) }
  'draw ' + @p.compile + ' ' + compile_options + ";\n"
end

#compilewithscale(xscale, yscale) ⇒ Object



148
149
150
151
152
# File 'lib/simpleplot.rb', line 148

def compilewithscale(xscale, yscale)
  @p = Path.new
  @x.each_index{ |i| @p.add_pair(Pair.new((@x[i]*xscale).cm, (@y[i]*yscale).cm)) }
  'draw ' + @p.compile + ' ' + compile_options + ";\n"
end