This notebook describes plots that can be drawn using Gruff in Daru.
Lets change the plotting library to Gruff.
require 'daru'
Daru.plotting_library = :gruff
:gruff
df = Daru::DataFrame.new({
a: [1, 3, 5, 7, 5, 0],
b: [1, 5, 2, 5, 1, 0],
c: [1, 6, 7, 2, 6, 0]
}, index: 'a'..'f')
df.plot type: :line
One can also select specific columns to display on x and y axis.
df.plot type: :line, x: :a, y: [:b, :c]
df.plot type: :scatter, x: :a, y: :b
df.plot type: :bar
Scatter plot can be differentiated by a category vector.
df = Daru::DataFrame.new({
a: [1, 2, 3, 4, 5],
b: [3, 2, 5, 1, 5],
c: [:a, :a, :a, :b, :b]
})
df.to_category :c
Daru::DataFrame(5x3) | |||
---|---|---|---|
a | b | c | |
0 | 1 | 3 | a |
1 | 2 | 2 | a |
2 | 3 | 5 | a |
3 | 4 | 1 | b |
4 | 5 | 5 | b |
df.plot type: :scatter, x: :a, y: :b, categorized: {by: :c}