Module: Daru::Plotting::Vector
- Included in:
- Vector
- Defined in:
- lib/daru/plotting/vector.rb
Instance Method Summary collapse
-
#plot(opts = {}) ⇒ Object
Plots a Vector with Nyaplot on IRuby using the given options.
Instance Method Details
#plot(opts = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/daru/plotting/vector.rb', line 18 def plot opts={} = { type: :scatter, title: "#{@name}", x_label: '', y_label: '', color: false }.merge(opts) x_axis = [:type] == :scatter ? Array.new(@size) { |i| i } : @index.to_a plot = Nyaplot::Plot.new plot.width([:width]) if [:width] plot.height([:height]) if [:height] p = plot.add( [:type], x_axis, @vector.to_a ) plot.x_label( [:x_label] ) if [:x_label] plot.y_label( [:y_label] ) if [:y_label] p.color( Nyaplot::Colors.qual ) if [:color] plot.show end |