Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Use Gnuplot With Ruby And Ruby On Rails

DZone's Guide to

Use Gnuplot With Ruby And Ruby On Rails

·
Free Resource
Gnuplot (http://gnuplot.sourceforge.net/) is a portable command-line driven interactive data and function plotting utility.

There is a Wrapper for Ruby:
* http://rubyforge.org/projects/rgplot/ 

Installation:
$> sudo gem install gnuplot

Use (example):

require 'gnuplot'
 
class DemosController < ApplicationController
 
  def index
 
    # tryout gnuplot
    Gnuplot.open do |gp|
      Gnuplot::Plot.new( gp ) do |plot|
 
        plot.xrange "[-10:10]"
        plot.title  "Sin Wave Example"
        plot.ylabel "x"
        plot.xlabel "sin(x)"
 
        plot.data << Gnuplot::DataSet.new( "sin(x)" ) do |ds|
          ds.with = "lines"
          ds.linewidth = 4
        end
 
      end
 
    end
 
 
    respond_to do |format|
      format.html # index.html.erb
    end
  end
 
end
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}