SciRuby / daru

Data Analysis in RUby
BSD 2-Clause "Simplified" License
1.04k stars 139 forks source link

DataFrame#plot and Vector#plot not working #482

Open lokeshh opened 5 years ago

lokeshh commented 5 years ago
require 'daru'
Daru.plotting_library = :gruff
dv = Daru::Vector.new [1, 2, 3]
dv.plot do |p|
  p.title = 'lol'
end

result in following error:

SystemStackError: stack level too deep
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru.rb:54:in `block in create_has_library'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:209:in `plotting_library='
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:1498:in `init_plotting_library'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:222:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
/var/lib/gems/2.5.0/gems/daru-0.2.1/lib/daru/vector.rb:224:in `plot'
...

If looks to me the support for plotting in Daru has been removed or long been broken because Daru latest release gives the error that DataFrame#plot is not found. If the support for plotting has been removed (because its shifted to daru-view) we need to remove the appropriate notebooks from README and sciruby-notebooks.

Shekharrajak commented 5 years ago

If the support for plotting has been removed (because its shifted to daru-view) we need to remove the appropriate notebooks from README and sciruby-notebooks.

I don't think it is removed from the daru. It looks different issue. I am able to run these lines using latest code.

lokeshh commented 5 years ago

@Shekharrajak Ok, but these lines are certainly not working in latest daru release.

NoMethodError: undefined method `plot' for "#<Daru::Vector(3)>\n   0   1\n   1   2\n   2   3"
    from /var/lib/gems/2.3.0/gems/daru-0.2.1/lib/daru/vector.rb:1420:in `method_missing'
    from (irb):4
    from /usr/bin/irb:11:in `<main>'
lokeshh commented 5 years ago

@Shekharrajak Also I'm getting error (the same I mentioned on top) on latest code. You might want to test on a new computer with only latest daru installed because that's what I did.

Shekharrajak commented 5 years ago

Yes! I already tried the latest cloned version :

 ➜  daru git:(master*) bundle console 
irb(main):001:0> require 'daru'
=> false
irb(main):002:0> Daru.plotting_library = :gruff
=> :gruff
irb(main):003:0> dv = Daru::Vector.new [1, 2, 3]
=> #<Daru::Vector(3)>
   0   1
   1   2
   2   3
irb(main):004:0> dv.plot do |p|
irb(main):005:1*   p.title = 'lol'
irb(main):006:1> end
=> #<Gruff::Bar:0x000055ae4fac16a8 @columns=500.0 .................

I'll check 0.2.1

lokeshh commented 5 years ago

@Shekharrajak You are right, #plot is working in latest code. I hadn't installed gruff, so it was giving this weird error.

Shekharrajak commented 5 years ago

Thanks for the update. Actually, I tried in 0.2.1 version also it was fine.

lokeshh commented 5 years ago

I think a new Daru release is needed as with the last release the sciruby-notebooks won't be working. Also could you verify if gnuplot working for you?

Following lines give me Illegal seek error. What about you?

require 'gnuplotrb'
require 'daru'
include GnuplotRB

dv = Daru::Vector.new [:a, :a, :a, :b, :b], type: :category
Plot.new [dv.frequencies, with: 'histogram'], xrange: -1..2, yrange: 0..10
Shekharrajak commented 5 years ago

@lokeshh , I installed gnuplotrb gem and run sudo apt-get install gnuplot-x11. It worked for me.

lokeshh commented 5 years ago

Ok thanks.

homonecloco commented 4 years ago

Hi, I'm having the same error, I'm using Daru-0.2.2. Is this something fixed in the master branch? And if so, are you planning to do a release at some point? I prefer to use a fixed release for consistency. Best, Ricardo.

NicolasNeiman commented 3 years ago

Hi @lokeshh and @v0dro,

I'm using daru (0.3) and I'm getting the same error SystemStackError: stack level too deep Do you have the same issue on your end ?

lokeshh commented 3 years ago

@NicolasNeiman You need to install gruff gem first. You can do that by running gem install gruff.

lokeshh commented 3 years ago

@homonecloco I'm using daru 0.3 and plotting with gruff is working for me. I just had to add that gem using gem install gruff. If you see an error let me know.