File: histtest.rb

package info (click to toggle)
ruby-gnuplot 2.6.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 224 kB
  • sloc: ruby: 456; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 448 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
require 'gnuplot'

Gnuplot.open do |gp|
    gp << "bin(x, s) = s*int(x/s)\n"

    Gnuplot::Plot.new( gp ) do |plot|
	plot.title  "Histogram"
	plot.xlabel "x"
	plot.ylabel "frequency"
  plot.set "terminal", "dumb"

	x = (0..500).collect { |v| (rand()-0.5)**3 }
	plot.data << Gnuplot::DataSet.new( [x] ) do |ds|
	    ds.title = "smooth frequency" 
	    ds.using = "(bin($1,.01)):(1.)"
	    ds.smooth = "freq"
	    ds.with = "boxes"
	end
    end
end