Forum: Ruby SVG::Graph::Plot

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
038916198a1d0851ad45f58194f5fbcf?d=identicon&s=25 Raymond Law (rlaw)
on 2007-03-22 16:06
I encountered a problem when using SVG::Graph.  I have the following
code that generate a simple plot:

require 'SVG/Graph/Plot'

# This does not work.
data= [0.107,9, 0.128,1, 0.163,2, 0.188,4, 0.192,6, 0.5,5.5]

# This works fine.
#data= [0.107,9, 0.128,1, 0.163,2, 0.188,4, 0.192,6, 1.5,5.5]

graph ={
  :height => 500,
  :width => 800,
  :key => true,
  :scale_x_integers => true,
  :scale_y_integerrs => true,

  :data => data,
  :title => 'Projected'

f ="plot.svg", "w+")

The error is:

123 rlaw ~/svg_graph/test > ruby plot.rb
/usr/local/lib/ruby/site_ruby/1.8/SVG/Graph/Plot.rb:206:in `-': nil
can't be coerced into Float (TypeError)
        from /usr/local/lib/ruby/site_ruby/1.8/SVG/Graph/Plot.rb:206:in
        from /usr/local/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:522:in
        from /usr/local/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:488:in
        from /usr/local/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:203:in
        from plot.rb:19
124 rlaw ~/svg_graph/test >

Basically, when x's are very small (i.e. smaller than 1?), I get the
above error.  Is this a known bug, or am I just not using it right?

Thank you.

This topic is locked and can not be replied to.