File: x15.tcl

package info (click to toggle)
plplot 5.3.1-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 26,248 kB
  • ctags: 11,687
  • sloc: ansic: 86,045; xml: 17,249; sh: 12,400; tcl: 8,113; cpp: 6,824; perl: 4,383; python: 3,915; makefile: 2,899; java: 2,788; fortran: 290; sed: 5; awk: 1
file content (126 lines) | stat: -rw-r--r-- 2,985 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#----------------------------------------------------------------------------
# $Id: x15.tcl,v 1.9 2002/01/15 02:43:57 airwin Exp $
#----------------------------------------------------------------------------

proc x15 {{w loopback}} {
  set xpts 35
  set ypts 46
  matrix z f $xpts $ypts
  # Comment out set up of cmap0 with limited number of colours
  # $w cmd plscmap0n 3
  # Comment out set up of cmap1 since actually cmap0 is used, and to
  # fiddle with this affects other tcl plots bundled with this example.
  # cmap1_init152 $w

  for {set i 0} {$i < $xpts} {incr i} {
    set x [expr ($i - ($xpts/2)) / double($xpts/2)]
    for {set j 0} {$j < $ypts} {incr j} {
      set y [expr ($j - double($ypts/2)) / double($ypts/2) - 1.]

      z $i $j = [expr $x*$x - $y*$y + ($x - $y)/($x * $x + $y * $y + .1) ]
    }
  }
  set zmin [z 0 0]
  set zmax $zmin
  for {set i 0} {$i < $xpts} {incr i} {
    for {set j 0} {$j < $ypts} {incr j} {
      if {[z $i $j] < $zmin} { set zmin [z $i $j] }
      if {[z $i $j] > $zmax} { set zmax [z $i $j] }
    }
  }
  plot151 $w $z $zmin $zmax
  plot152 $w $z $zmin $zmax
  
}

proc  cmap1_init152 { w } {

  matrix i f 4
  matrix h f 4
  matrix l f 4
  matrix s f 4
  matrix rev f 4
  i 0 = 0.0
  i 1 = 0.45
  i 2 = 0.55
  i 3 = 1.0

  h 0 = 260.0
  h 1 = 260.0
  h 2 = 20.0
  h 3 = 20.0

  l 0 = 0.6
  l 1 = 0.0
  l 2 = 0.0
  l 3 = 0.6

  s 0 = 1.0
  s 1 = 0.5
  s 2 = 0.5
  s 3 = 1.0
  
  rev 0 = 0
  rev 1 = 0
  rev 2 = 0
  rev 3 = 0

  $w cmd plscmap1l 0 4 i h l s rev
}
proc plot151 { w z zmin zmax } {

  set sh_width 2
  set min_color 9
  set max_color 2
  set min_width 2
  set max_width 2
  # N.B. this flag set to use cmap0
  set sh_cmap 0

  set shade_min [expr $zmin + ($zmax - $zmin)*.4 ]
  set shade_max [expr $zmin + ($zmax - $zmin)*.6 ]
  set sh_color 7

  $w cmd pladv 0
  $w cmd plvpor .1 .9 .1 .9
  $w cmd plwind -1.0 1.0 -1.0 1.0

  $w cmd plpsty 8
  $w cmd plshade z -1. 1. -1. 1. $shade_min $shade_max \
    $sh_cmap $sh_color $sh_width \
    $min_color $min_width $max_color $max_width 1
  $w cmd plcol0 1
  $w cmd plbox bcnst 0.0 0 bcnstv 0.0 0
  $w cmd plcol0 2
  $w cmd pllab "distance" "altitude" "Bogon flux"
}

proc plot152 { w z zmin zmax } {

  set sh_width 2
  set min_color 0
  set max_color 0
  set min_width 0
  set max_width 0
  # N.B. this flag set to use cmap0
  set sh_cmap 0

  $w cmd pladv 0
  $w cmd plvpor .1 .9 .1 .9
  $w cmd plwind -1.0 1.0 -1.0 1.0
  for {set i 0} {$i < 10} {incr i} {
    set shade_min [expr $zmin + ($zmax - $zmin)*$i/10.0 ]
    set shade_max [expr $zmin + ($zmax - $zmin)*($i + 1)/10.0 ]
    set sh_color [expr $i + 6]
    $w cmd plpsty [expr ($i + 2) % 8 + 1]
    $w cmd plshade z -1. 1. -1. 1. $shade_min $shade_max \
      $sh_cmap $sh_color $sh_width \
      $min_color $min_width $max_color $max_width 1
  }
  $w cmd plcol0 1
  $w cmd plbox bcnst 0.0 0 bcnstv 0.0 0
  $w cmd plcol0 2
  $w cmd pllab "distance" "altitude" "Bogon flux"
# Restore defaults
  $w cmd plcol0 1
}