Module: Daru::Plotting::DataFrame::NyaplotLibrary

Included in:
DataFrame
Defined in:
lib/daru/plotting/nyaplot/dataframe.rb

Instance Method Summary collapse

Instance Method Details

#plot(opts = {}, &block) ⇒ Object

Plots a DataFrame with Nyaplot on IRuby using the given options. Yields the corresponding Nyaplot::Plot object and the Nyaplot::Diagram object to the block, if it is specified. See the nyaplot docs for info on how to further use these objects.

Detailed instructions on use of the plotting API can be found in the notebooks whose links you can find in the README.

Options

  • :type - Type of plot. Can be :scatter, :bar, :histogram, :line or :box.

  • :x - Vector to be used for X co-ordinates.

  • :y - Vector to be used for Y co-ordinates.

Usage

# Simple bar chart
df = Daru::DataFrame.new({a:['A', 'B', 'C', 'D', 'E'], b:[10,20,30,40,50]})
df.plot type: :bar, x: :a, y: :b


23
24
25
26
27
28
29
# File 'lib/daru/plotting/nyaplot/dataframe.rb', line 23

def plot opts={}, &block
  if opts[:categorized]
    plot_with_category(opts, &block)
  else
    plot_without_category(opts, &block)
  end
end