clbustos / rubyvis

Ruby version of Protovis, a visualization toolkit.
http://clbustos.github.io/rubyvis
BSD 2-Clause "Simplified" License
240 stars 20 forks source link

Scale::Log: ticks() doesn't work as expected #9

Closed translunar closed 12 years ago

translunar commented 12 years ago

If I use xy = pv.Scale.linear(0, 1000).range(40, 400), then I can later draw rules using data xy.ticks(5).

But if I change it like so, xy = pv.Scale.log(1,1000).range(40,400), then data xy.ticks(5) gives an error message. Instead I have to do data [1,10,100,1000].

Here is the error:

/usr/local/lib/ruby/gems/1.9.1/gems/rubyvis-0.5.0/lib/rubyvis/scale/log.rb:30:in `ticks': wrong number of arguments (1 for 0) (ArgumentError)
from /home/jwoods/phenolog/paper/paper.rb:150:in `block (3 levels) in plot_correlation'
from /usr/local/lib/ruby/gems/1.9.1/gems/rubyvis-0.5.0/lib/rubyvis/mark/shorcut_methods.rb:18:in `instance_eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/rubyvis-0.5.0/lib/rubyvis/mark/shorcut_methods.rb:18:in `block in mark_method'
from /home/jwoods/phenolog/paper/paper.rb:149:in `block (2 levels) in plot_correlation'
from /usr/local/lib/ruby/gems/1.9.1/gems/rubyvis-0.5.0/lib/rubyvis/mark/shorcut_methods.rb:18:in `instance_eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/rubyvis-0.5.0/lib/rubyvis/mark/shorcut_methods.rb:18:in `block in mark_method'
from /home/jwoods/phenolog/paper/paper.rb:134:in `block in plot_correlation'
from /usr/local/lib/ruby/gems/1.9.1/gems/rubyvis-0.5.0/lib/rubyvis/mark.rb:470:in `instance_eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/rubyvis-0.5.0/lib/rubyvis/mark.rb:470:in `execute'
from /usr/local/lib/ruby/gems/1.9.1/gems/rubyvis-0.5.0/lib/rubyvis/mark.rb:459:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/rubyvis-0.5.0/lib/rubyvis/mark/panel.rb:17:in `initialize'
from /home/jwoods/phenolog/paper/paper.rb:94:in `new'
from /home/jwoods/phenolog/paper/paper.rb:94:in `plot_correlation'
from paper/plot_corr.rb:12:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/sciruby-0.1.3/lib/sciruby/plotter.rb:86:in `eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/sciruby-0.1.3/lib/sciruby/plotter.rb:86:in `block in eval_script'
from /usr/local/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
from /usr/local/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
from /usr/local/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
from /usr/local/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
from /usr/local/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
from /usr/local/lib/ruby/gems/1.9.1/gems/sciruby-0.1.3/lib/sciruby/plotter.rb:84:in `eval_script'
from /usr/local/lib/ruby/gems/1.9.1/gems/sciruby-0.1.3/lib/sciruby/plotter.rb:111:in `create_svg'
from /usr/local/lib/ruby/gems/1.9.1/gems/sciruby-0.1.3/lib/sciruby/plotter.rb:98:in `create_handle'
from /usr/local/lib/ruby/gems/1.9.1/gems/sciruby-0.1.3/lib/sciruby/plotter.rb:21:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/sciruby-0.1.3/bin/sciruby-plotter:12:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/sciruby-0.1.3/bin/sciruby-plotter:12:in `<top (required)>'
from /usr/local/bin/sciruby-plotter:19:in `load'
from /usr/local/bin/sciruby-plotter:19:in `<main>'

Looks like this is related to the other two open issues.

ghostd commented 12 years ago

The 'ticks' signature seems different between quantitative.rb and log.rb. The 'log' one does not take argument.

clbustos commented 12 years ago

I implemented an argument on Scale::Log.ticks, setting the numbers of subdivisions inside each base^x. For example, in your case you should use something like Scale::Log.ticks(1)