In [1]:
require 'daru'
require 'gnuplotrb'
include GnuplotRB
index = Daru::DateTimeIndex.date_range(:start => DateTime.new(2012,2,1), periods: 100)
vector = Daru::Vector.new(Array.new(10){ [1,2,3,4,5].shuffle }.flatten, index: index)
Out[1]:
In [2]:
vector_plot = Plot.new([vector, with: 'linespoints'], yrange: 0..6)
Out[2]:
In [3]:
vector_plot.xrange('["2012-02-16":"2012-02-26"]')
Out[3]:
In [4]:
df = Daru::DataFrame.new({
'Sales by Bill' => [1, 2, 3, 4, 5].shuffle,
'Sales by Martin' => [1, 2, 3, 4, 5].shuffle,
},
index: index
)
In [5]:
p = Plot.new(
df,
style_data: 'linespoints',
yrange: 0..6
)
Out[5]:
Format of datetime may be changed with format_x option:
In [6]:
p.format_x('%d/%m\n%H:%M')
Out[6]: