File: pghist.html

package info (click to toggle)
ruby-pgplot 0.1.3-6
  • links: PTS, VCS
  • area: contrib
  • in suites: wheezy
  • size: 480 kB
  • sloc: ruby: 1,382; ansic: 73; makefile: 37
file content (48 lines) | stat: -rw-r--r-- 1,329 bytes parent folder | download | duplicates (2)
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
39
40
41
42
43
44
45
46
47
48
<?xml version="1.0" ?>
<!DOCTYPE html 
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>pghist</title>
<link href="css.css" type="text/css" rel="stylesheet" />
</head>
<body>
<h1><a name="label-0" id="label-0">Ruby/PGPLOT example: pghist</a></h1><!-- RDLabel: "Ruby/PGPLOT example: pghist" -->
<h3><a name="label-1" id="label-1">code</a></h3><!-- RDLabel: "code" -->
<pre>require 'narray'
require 'pgplot'
include Pgplot

pgopen
srand(1)

# draw main Histogram of Normal distribution
data = NArray.sfloat(1000).randomn!
pghist(data, 31, -3.1..3.1, 0)

# draw sub Histogram of Normal distribution with gray bars
data = NArray.sfloat(200).randomn!*0.5 + 1 
pgsci(15)
pghist(data, 31, -3.1..3.1, 3)
pgsci(0)  # draw black frame
pghist(data, 31, -3.1..3.1, 1)

pgsci(1)
pgbox('BST', 0.0, 0, ' ', 0.0, 0)
pglab('Variate', ' ','PGPLOT Example 4:  Histograms (Gaussian)')

# draw Gaussian Curve
x = NArray.sfloat(620).indgen!*0.01 - 3.1
y = NMath.exp(-(x**2)*0.5) * (0.2*1000/NMath.sqrt(2*Math::PI))
pgline(x,y)</pre>
<h3><a name="label-2" id="label-2">output</a></h3><!-- RDLabel: "output" -->
<p><img src="pghist.png" alt="pghist.png"/></p>

<hr/>
<a href="./">Ruby/PGPLOT</a>
by Masahiro Tanaka


</body>
</html>