How to Install RMagick on MacOS - Generate graphs with Ruby
1. Installing MacPorts
Download dog package from : https://distfiles.macports.org/MacPorts/MacPorts-2.1.1-10.7-Lion.pkg
Run this command:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
2. Installing ImageMagick
sudo port install tiff -macosx imagemagick +q8 +gs +wmf
3. Installing RMagick
sudo gem install rmagick
*FOR MORE DETAILS http://rmagick.rubyforge.org/install-osx.html
4. And now, you can generate your first graphs with ruby ;)
#!/usr/bin/ruby
require 'rubygems'
require 'gruff'
g = Gruff::Line.new
g.title = "My Graph"
g.data("Apples", [1, 2, 3, 4, 4, 3])
g.data("Oranges", [4, 8, 7, 9, 8, 9])
g.data("Watermelon", [2, 3, 1, 5, 6, 8])
g.data("Peaches", [9, 9, 10, 8, 7, 9])
g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}
g.write('my_fruity_graph.png')
No comments:
Post a Comment