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
|
require 'gnuplot'
# File.open( "gnuplot.dat", "w") do |gp|
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.set "terminal", "dumb"
x = (0..50).collect { |v| v.to_f }
y = x.collect { |v| v ** 2 }
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
|