require 'daru/view'
Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions. Install the mechanize gem version ~>2.7.5 for using mechanize functions.
true
df = Daru::DataFrame.new(
{
a: [1, 2, 3, 4, 5, 6],
b: [1, 5, 2, 5, 1, 0],
c: [1, 6, 7, 2, 6, 0]
}, index: 'a'..'f'
)
a | b | c | |
---|---|---|---|
a | 1 | 1 | 1 |
b | 2 | 5 | 6 |
c | 3 | 2 | 7 |
d | 4 | 5 | 2 |
e | 5 | 1 | 6 |
f | 6 | 0 | 0 |
plt = Daru::View::Plot.new(df, type: :line, x: :a, y: :c)
#<Daru::View::Plot:0x00000003ec4458 @data=#<Daru::DataFrame(6x3)> a b c a 1 1 1 b 2 5 6 c 3 2 7 d 4 5 2 e 5 1 6 f 6 0 0, @options={:type=>:line, :x=>:a, :y=>:c}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x00000003ec42f0 @properties={:diagrams=>[#<Nyaplot::Diagram:0x00000003eae720 @properties={:type=>:line, :options=>{:x=>:a, :y=>:c}, :data=>"dd735a9c-1a93-440f-ab9f-db39f5e11f96"}, @xrange=[1, 6], @yrange=[0, 7]>], :options=>{}}>>
plt.show_in_iruby
Daru::View.plotting_library = :nyaplot
:nyaplot
plt2 = Daru::View::Plot.new(df)
#<Daru::View::Plot:0x00000003dd7d10 @data=#<Daru::DataFrame(6x3)> a b c a 1 1 1 b 2 5 6 c 3 2 7 d 4 5 2 e 5 1 6 f 6 0 0, @options={}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x00000003dd7c20 @properties={:diagrams=>[], :options=>{}}>>
plt2.show_in_iruby
dv = Daru::Vector.new [1, 2, 3]
0 | 1 |
1 | 2 |
2 | 3 |
plt3 = Daru::View::Plot.new(dv)
#<Daru::View::Plot:0x00000003ca2ad0 @data=#<Daru::Vector(3)> 0 1 1 2 2 3, @options={}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x00000003ca2990 @properties={:diagrams=>[#<Nyaplot::Diagram:0x00000003ca1bd0 @properties={:type=>:scatter, :options=>{:x=>"data0", :y=>"data1"}, :data=>"56256933-852f-4161-9749-01d058a05cd0"}, @xrange=[0, 2], @yrange=[1, 3]>], :options=>{}}>>
plt3.show_in_iruby
plt3 = Daru::View::Plot.new(dv, type: :line)
#<Daru::View::Plot:0x00000003c1c7f0 @data=#<Daru::Vector(3)> 0 1 1 2 2 3, @options={:type=>:line}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x00000003c1c700 @properties={:diagrams=>[#<Nyaplot::Diagram:0x00000003c17c78 @properties={:type=>:line, :options=>{:x=>"data0", :y=>"data1"}, :data=>"dd9c528c-6fb4-44ef-abc9-0f9cabc53149"}, @xrange=[0, 2], @yrange=[1, 3]>], :options=>{}}>>
plt3.show_in_iruby