File: pgimag.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 (56 lines) | stat: -rw-r--r-- 1,595 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
49
50
51
52
53
54
55
56
<?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>pgimag</title>
<link href="css.css" type="text/css" rel="stylesheet" />
</head>
<body>
<h1><a name="label-0" id="label-0">Ruby/PGPLOT example: pgimag</a></h1><!-- RDLabel: "Ruby/PGPLOT example: pgimag" -->
<h3><a name="label-1" id="label-1">code</a></h3><!-- RDLabel: "code" -->
<pre>require 'narray'
require 'pgplot'
include Pgplot

# set color table
def palett
  rl = [-0.5, 0.0, 0.17, 0.33, 0.50, 0.67, 0.83, 1.0, 1.7]
  rr = [ 0.0, 0.0,  0.0,  0.0,  0.6,  1.0,  1.0, 1.0, 1.0]
  rg = [ 0.0, 0.0,  0.0,  1.0,  1.0,  1.0,  0.6, 0.0, 1.0]
  rb = [ 0.0, 0.3,  0.8,  1.0,  0.3,  0.0,  0.0, 0.0, 1.0]
  pgctab(rl, rr, rg, rb)
end

# prepare Data
nx = 64
ny = 64
x = NArray.sfloat(nx,1).indgen!(1)
y = NArray.sfloat(1,ny).indgen!(1)
f = NMath.cos( NMath.sqrt(x*(80.0/nx))*0.6 - y*16.0/(3.0*ny) ) *
    NMath.cos( x*16.0/(3.0*nx) ) +
    (x/nx - y/ny) + NMath.sin(NMath.sqrt(x**2+y**2))*0.05

# draw Image Map
pgopen
pgwnad(0.0, 1.0+nx, 0.0, 1.0+ny)
palett
pgimag(f)
pgmtxt('t',1.0,0.0,0.0,'PGIMAG, PGWEDG, and PGCTAB')

# draw Color Bar at bottom
pgsch(0.6)
pgbox('bcntsi',0.0,0,'bcntsiv',0.0,0)
pgmtxt('b',3.0,1.0,1.0,'pixel number')
pgwedg('RI', 4.0, 5.0, f.min,f.max, 'pixel value')</pre>
<h3><a name="label-2" id="label-2">output</a></h3><!-- RDLabel: "output" -->
<p><img src="pgimag.png" alt="pgimag.png"/></p>

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


</body>
</html>