This post originated from an RSS feed registered with Ruby Buzz
by Michael Neumann.
Original Post: Using Ploticus from Ruby
Feed Title: Mike's Weblog
Feed URL: http://www.ntecs.de/blog-old/index.rss?cat=ruby&count=7
Feed Description: Blogging about Ruby and other interesting stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Michael Neumann
Latest Posts From Mike's Weblog
Advertisement
Ploticus is a nice tool to
generate diagrams. I wrote a nice wrapper in 143 lines of Ruby code, which
makes it easy to use. See yourself:
require ' ploticus '
pl = Ploticus .new
pl.data = (0 ..10 ).map {|x| [x, x**2 ]}
pl.area {|a|
a.title = " The title of this plot "
a.xrange = [0 ,10 ]
a.yrange = [0 ,100 ]
}
pl.xaxis {|a|
a.stubs = " incremental "
a.label = " x "
}
pl.yaxis {|a|
a.stubs = " incremental 10 "
a.label = " x^2 "
a.grid = {:color => " blue " }
}
pl.lineplot {|a|
a.xfield = 1 # use first column for x
a.yfield = 2 # use second column for y
a.linedetails = {:color => " red " }
}
puts pl.plot!
And the result is:
You can download my ruby-ploticus library from: ntecs.de/viewcvs/viewcvs/ruby-ploticus/
A more advanced example with four plots on a page can be found here .
The diagram it generates is shown below:
Read: Using Ploticus from Ruby