Module: Daru::Plotting::DataFrame::GruffLibrary

Defined in:
lib/daru/plotting/gruff/dataframe.rb

Instance Method Summary collapse

Instance Method Details

#plot(opts = {}) {|plot| ... } ⇒ Object

Yields:



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/daru/plotting/gruff/dataframe.rb', line 5

def plot opts={}
  type = opts[:type] || :bar
  size = opts[:size] || 500
  x = extract_x_vector opts[:x]
  y = extract_y_vectors opts[:y]
  type = process_type type, opts[:categorized]
  case type
  when :line, :bar, :scatter
    plot = send("#{type}_plot", size, x, y)
  when :scatter_categorized
    plot = scatter_with_category(size, x, y, opts[:categorized])
  # TODO: hist, box
  # It turns out hist and box are not supported in Gruff yet
  else
    raise ArgumentError, 'This type of plot is not supported.'
  end
  yield plot if block_given?
  plot
end