In [1]:
require 'daru/view'
Out[1]:
true
In [2]:
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'
    )
Out[2]:
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
In [3]:
plt = Daru::View::Plot.new(df, type: :line, x: :a, y: :c)
Out[3]:
#<Daru::View::Plot:0x0000563b87f127c8 @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}, @user_options={}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x0000563b87f12278 @properties={:diagrams=>[#<Nyaplot::Diagram:0x0000563b885c2960 @properties={:type=>:line, :options=>{:x=>:a, :y=>:c}, :data=>"e9dbabdd-529b-43ad-b0d1-3e5f3ce52e8a"}, @xrange=[1, 6], @yrange=[0, 7]>], :options=>{}}>>
In [4]:
plt.show_in_iruby
In [5]:
Daru::View.plotting_library = :nyaplot
Out[5]:
:nyaplot
In [14]:
plt2 = Daru::View::Plot.new(df, type: :line, x: :a, y: :b)
Out[14]:
#<Daru::View::Plot:0x0000563b87f39e40 @data=#<Daru::DataFrame(6x4)>
             a      b      c _index
      a      1      1      1      a
      b      2      5      6      b
      c      3      2      7      c
      d      4      5      2      d
      e      5      1      6      e
      f      6      0      0      f, @options={:type=>:line, :x=>:a, :y=>:b}, @user_options={}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x0000563b87f39cd8 @properties={:diagrams=>[#<Nyaplot::Diagram:0x0000563b87f194d8 @properties={:type=>:line, :options=>{:x=>:a, :y=>:b}, :data=>"e3fe52e6-318d-4bd8-a2f8-17125c18ae99"}, @xrange=[1, 6], @yrange=[0, 5]>], :options=>{}}>>
In [15]:
plt2.show_in_iruby
In [8]:
dv = Daru::Vector.new [1, 2, 3]
Out[8]:
Daru::Vector(3)
0 1
1 2
2 3
In [9]:
plt3 = Daru::View::Plot.new(dv)
Out[9]:
#<Daru::View::Plot:0x0000563b8826d288 @data=#<Daru::Vector(3)>
   0   1
   1   2
   2   3, @options={}, @user_options={}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x0000563b8826cdd8 @properties={:diagrams=>[#<Nyaplot::Diagram:0x0000563b8825ff98 @properties={:type=>:scatter, :options=>{:x=>"data0", :y=>"data1"}, :data=>"cbc890cd-8515-42d1-b602-9a8b73730e05"}, @xrange=[0, 2], @yrange=[1, 3]>], :options=>{}}>>
In [10]:
plt3.show_in_iruby
In [11]:
plt3 = Daru::View::Plot.new(dv, type: :line)
Out[11]:
#<Daru::View::Plot:0x0000563b87c7ce28 @data=#<Daru::Vector(3)>
   0   1
   1   2
   2   3, @options={:type=>:line}, @user_options={}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x0000563b87c7cce8 @properties={:diagrams=>[#<Nyaplot::Diagram:0x0000563b87c6ce60 @properties={:type=>:line, :options=>{:x=>"data0", :y=>"data1"}, :data=>"25695513-300d-4e41-9868-ff59fb0ec7b3"}, @xrange=[0, 2], @yrange=[1, 3]>], :options=>{}}>>
In [12]:
plt3.show_in_iruby
In [ ]: