Class: RubyPost::StemPlot
- Inherits:
-
AbstractPlot
- Object
- Object
- BaseDrawCommand
- AbstractPlot
- RubyPost::StemPlot
- Defined in:
- lib/simpleplot.rb
Instance Attribute Summary
Attributes inherited from AbstractPlot
Attributes inherited from BaseDrawCommand
Instance Method Summary collapse
- #compile ⇒ Object
- #compilewithscale(xscale, yscale) ⇒ Object
-
#initialize(x, y) ⇒ StemPlot
constructor
Intitalise with two arrays of the same size.
Methods inherited from AbstractPlot
Methods inherited from BaseDrawCommand
#add_option, #color, #colour, #compile_options, #rotate, #scale, #set_drawable, #translate
Constructor Details
#initialize(x, y) ⇒ StemPlot
Intitalise with two arrays of the same size.
209 210 211 212 213 |
# File 'lib/simpleplot.rb', line 209 def initialize(x, y) super() @x = x @y = y end |
Instance Method Details
#compile ⇒ Object
215 216 217 218 219 220 221 222 |
# File 'lib/simpleplot.rb', line 215 def compile str = '' @x.each_index{ |i| str = str + 'draw (' + @x[i].to_s + 'cm, 0)--(' + @x[i].to_s + 'cm, ' + @y[i].to_s + 'cm) ' + + ";\n" str = str + 'fill fullcircle scaled (0.1cm) shifted (' + @x[i].to_s + 'cm, ' + @y[i].to_s + 'cm) ' + + ";\n" } return str end |
#compilewithscale(xscale, yscale) ⇒ Object
224 225 226 227 228 229 230 231 |
# File 'lib/simpleplot.rb', line 224 def compilewithscale(xscale, yscale) str = '' @x.each_index{ |i| str = str + 'draw (' + (@x[i]*xscale).to_s + 'cm, 0)--(' + (@x[i]*xscale).to_s + 'cm, ' + (@y[i]*yscale).to_s + 'cm) ' + + ";\n" str = str + 'fill fullcircle scaled (0.1cm) shifted (' + (@x[i]*xscale).to_s + 'cm, ' + (@y[i]*yscale).to_s + 'cm) ' + + ";\n" } return str end |