File: gnuplot.rb

package info (click to toggle)
ruby-gsl 2.1.0.3%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,820 kB
  • sloc: ansic: 62,229; ruby: 15,845; sh: 19; makefile: 11
file content (38 lines) | stat: -rwxr-xr-x 703 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env ruby
# Turn on warnings
$-w = true

require 'gnuplot'
require 'gsl'
require 'gsl/gnuplot';

# Plot using gnuplot
Gnuplot.open do |gp|
  Gnuplot::Plot.new( gp ) do |plot|

    plot.xrange "[0:10]"
    plot.yrange "[-1.5:1.5]"
    plot.title  "Sin Wave Example"
    plot.xlabel "x"
    plot.ylabel "sin(x)"
    plot.pointsize 3
    plot.grid

    x = GSL::Vector[0..10]
    y = GSL::Sf::sin(x)

    plot.data = [
      Gnuplot::DataSet.new( "sin(x)" ) { |ds|
        ds.with = "lines"
        ds.title = "String function"
        ds.linewidth = 4
      },

      Gnuplot::DataSet.new( [x, y] ) { |ds|
        ds.with = "linespoints"
        ds.title = "Array data"
      }
    ]

  end
end