File: pgimag.rd

package info (click to toggle)
ruby-pgplot 0.1.9-3
  • links: PTS, VCS
  • area: contrib
  • in suites: buster, stretch
  • size: 604 kB
  • ctags: 144
  • sloc: ruby: 1,607; makefile: 76; ansic: 57; sh: 17
file content (46 lines) | stat: -rw-r--r-- 1,061 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
39
40
41
42
43
44
45
46
=begin
= Ruby/PGPLOT example: pgimag

=== code

  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')

=== output

<<< pgimag.png

<<< trailer
=end