Method: UnicodePlot.scatterplot

Defined in:
lib/unicode_plot/scatterplot.rb

.scatterplot(*args, canvas: :braille, color: :auto, name: "", **kw) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/unicode_plot/scatterplot.rb', line 5

module_function def scatterplot(*args,
                                canvas: :braille,
                                color: :auto,
                                name: "",
                                **kw)
  case args.length
  when 1
    # y only
    y = Array(args[0])
    x = Array(1 .. y.length)
  when 2
    # x and y
    x = Array(args[0])
    y = Array(args[1])
  else
    raise ArgumentError, "worng number of arguments"
  end

  plot = Scatterplot.new(x, y, canvas, **kw)
  scatterplot!(plot, x, y, color: color, name: name)
end