Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nil in data passed to graphs #53

Open
v0dro opened this issue Aug 5, 2015 · 5 comments
Open

Allow nil in data passed to graphs #53

v0dro opened this issue Aug 5, 2015 · 5 comments

Comments

@v0dro
Copy link

v0dro commented Aug 5, 2015

Currently when I pass a nil in an Array for plotting, nyaplot returns an error.

It would be great if it could handle nils properly by not plotting the points where they appear, like GNU plot.

Here's some example code:

require 'nyaplot'

p = Nyaplot::Plot.new
p.add(:scatter, [10,nil,30], [0,1,2])
p.show
#ArgumentError: comparison of NilClass with 10 failed
@tansaku
Copy link

tansaku commented Nov 17, 2015

I seem to get this error even when I don't have a nil in the data - trying to do a boxplot, with more than one set of data ...

    puts dec2014
    puts '----'
    puts mar2015
    plot.add(:box, dec2014.compact, mar2015.compact)

gives

157.0
298
157.0
134.0
298
298
298
298
298
135.0
298
298
206.0
240.0
298
177.0
184.0
151.0
228.0
140.0
298
277.0
140.0
134.0
204.0
162.0
298
----
207.0
123.0
120.0
298
298
298
123.0
149.0
78.0
298
200.0
298
108.0
298
298
298
298
298
123.0
192.0
171.0
298
/Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/diagram.rb:285:in `each': comparison of NilClass with 78.0 failed (ArgumentError)
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/diagram.rb:285:in `min'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/diagram.rb:285:in `block in process_data'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/diagram.rb:290:in `call'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/diagram.rb:290:in `block in process_data'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/diagram.rb:290:in `each'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/diagram.rb:290:in `process_data'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/diagram.rb:16:in `initialize'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/plot.rb:75:in `new'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/plot.rb:75:in `add_with_df'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/plot.rb:64:in `add'
    from lib/correlation.rb:127:in `block in <main>'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/statsample-2.0.1/lib/statsample/analysis/suite.rb:20:in `instance_eval'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/statsample-2.0.1/lib/statsample/analysis/suite.rb:20:in `run'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/statsample-2.0.1/lib/statsample/analysis.rb:73:in `block in add_to_reportbuilder'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/statsample-2.0.1/lib/statsample/analysis.rb:69:in `each'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/statsample-2.0.1/lib/statsample/analysis.rb:69:in `add_to_reportbuilder'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/statsample-2.0.1/lib/statsample/analysis.rb:91:in `to_text'
    from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/statsample-2.0.1/lib/statsample/analysis.rb:97:in `run_batch'
    from lib/correlation.rb:163:in `<main>'

@tansaku
Copy link

tansaku commented Nov 17, 2015

ah, because I have arrays of different lengths?

@domitry
Copy link
Owner

domitry commented Nov 17, 2015

Oops that's true.. but it's bug.

domitry added a commit that referenced this issue Nov 17, 2015
@tansaku
Copy link

tansaku commented Nov 17, 2015

thanks @domitry - is there any quick fix I can do for this - was hoping to show some box plots at a presentation tomorrow :-) I guess I can get that via:

gem 'nyaplot', :git => 'git://github.com/domitry/nyaplot.git'

before it gets into the gem itself

@domitry
Copy link
Owner

domitry commented Nov 17, 2015

moved to #57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants