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]
  if opts[:categorized]
    return plot_with_category(size, type, x, y, opts[:categorized])
  end
  case type
  when :line, :bar, :scatter
    plot = send("#{type}_plot", size, x, y)
  # 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