/usr/share/doc/libplplot12/examples/tcl/x08.tcl is in plplot-tcl-dev 5.10.0+dfsg2-0.1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | #----------------------------------------------------------------------------
# $Id: x08.tcl 11680 2011-03-27 17:57:51Z airwin $
#
# Copyright (C) 2004 Alan W. Irwin
#
# This file is part of PLplot.
#
# PLplot is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PLplot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with PLplot; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#----------------------------------------------------------------------------
# Does a series of 3-d plots for a given data set, with different
# viewing options in each plot.
# Routine for restoring colour map1 to default.
# See static void plcmap1_def(void) in plctrl.c for reference.
proc restore_cmap1_8 {w} {
# For center control points, pick black or white, whichever is closer to bg
# Be careful to pick just short of top or bottom else hue info is lost
$w cmd plgcolbg rbg gbg bbg
set vertex [expr {($rbg + $gbg + $bbg)/(3.*255.)}]
if {$vertex < 0.5} {
set vertex 0.01
set midpt 0.10
} else {
set vertex 0.99
set midpt 0.90
}
# Independent variable of control points.
matrix i f 6 = {0., 0.44, 0.50, 0.50, 0.56, 1.}
# Hue for control points. Blue-violet to red
matrix h f 6 = {260., 260., 260., 0., 0., 0.}
# Lightness ranging from medium to vertex to medium
# double quotes required rather than braces so that variables
# get evaluated for initialization.
matrix l f 6 = "0.5, $midpt, $vertex, $vertex, $midpt, 0.5"
# Saturation is complete for default
matrix s f 6 = {1., 1., 1., 1., 1., 1.}
# Integer flag array is zero (no interpolation along far-side of colour
# figure)
matrix rev i 6 = {0, 0, 0, 0, 0, 0}
# Default number of cmap1 colours
$w cmd plscmap1n 128
# Interpolate between control points to set up default cmap1.
$w cmd plscmap1l 0 6 i h l s rev
}
# Routine for initializing color map 1 in HLS space.
# Basic grayscale variation from half-dark (which makes more interesting
# looking plot compared to dark) to light.
proc cmap1_init_8 {w gray} {
# Independent variable of control points.
matrix i f 2 = {0., 1.}
if {$gray == 1} {
# Hue for control points. Doesn't matter since saturation is zero.
matrix h f 2 = {0., 0.}
# Lightness ranging from half-dark (for interest) to light.
matrix l f 2 = {0.5, 1.}
# Gray scale has zero saturation.
matrix s f 2 = {0., 0.}
} else {
# Hue ranges from blue (240 deg) to red (0 or 360 deg)
matrix h f 2 = {240., 0.}
# Lightness and saturation are constant (values taken from C example).
matrix l f 2 = {0.6, 0.6}
matrix s f 2 = {0.8, 0.8}
}
# Integer flag array is zero (no interpolation along far-side of colour
# figure
matrix rev i 2 = {0, 0}
# Number of cmap1 colours is 256 in this case.
$w cmd plscmap1n 256
# Interpolate between control points to set up default cmap1.
$w cmd plscmap1l 0 2 i h l s rev
}
proc x08 {{w loopback}} {
# these should be defined elsewhere.
set rosen 1
matrix alt f 2 = {60.0, 20.0}
matrix az f 2 = {30.0, 60.0}
set xpts 35
set ypts 46
set n_col 256
set two_pi [expr {2.0 * $::PLPLOT::PL_PI} ]
matrix x f $xpts
matrix y f $ypts
matrix z f $xpts $ypts
for {set i 0} {$i < $xpts} {incr i} {
x $i = [expr {($i - ($xpts/2)) / double($xpts/2)} ]
if {$rosen == 1} {
x $i = [expr {1.5* [x $i]}]
}
}
for {set i 0} {$i < $ypts} {incr i} {
y $i = [expr {($i - ($ypts/2)) / double($ypts/2)} ]
if {$rosen == 1} {
y $i = [expr {0.5 + [y $i]}]
}
}
for {set i 0} {$i < $xpts} {incr i} {
set xx [x $i]
for {set j 0} {$j < $ypts} {incr j} {
set yy [y $j]
if {$rosen == 1} {
z $i $j = [expr {(pow(1. - $xx,2) + \
100 * pow($yy - pow($xx,2),2))}]
set zz [z $i $j]
if {$zz > 0.} {
z $i $j = [expr {log($zz)}]
} else {
z $i $j = [expr {-5.0}]
}
} else {
set r [expr {sqrt( $xx * $xx + $yy * $yy )} ]
z $i $j = [expr {exp(-$r * $r) * cos( $two_pi * $r )} ]
}
}
}
set zmin [z min [ expr $xpts * $ypts]]
set zmax [z max [ expr $xpts * $ypts]]
set nlev 10
matrix clev f $nlev
set step [expr {($zmax-$zmin)/($nlev+1)}]
for {set i 0} {$i < $nlev} {incr i} {
clev $i = [expr {$zmin + ($i+1) * $step}]
}
$w cmd pllightsource 1. 1. 1.
for {set k 0} {$k < 2} {incr k} {
for {set ifshade 0} {$ifshade < 4} {incr ifshade} {
$w cmd pladv 0
$w cmd plvpor 0.0 1.0 0.0 0.9
$w cmd plwind -1.0 1.0 -0.9 1.1
$w cmd plcol0 3
set title [format "#frPLplot Example 8 - Alt=%.0f, Az=%.0f" \
[alt $k] [az $k]]
$w cmd plmtex "t" 1.0 0.5 0.5 $title
$w cmd plcol0 1
if {$rosen == 1} {
$w cmd plw3d 1.0 1.0 1.0 -1.5 1.5 -0.5 1.5 $zmin $zmax [alt $k] [az $k]
} else {
$w cmd plw3d 1.0 1.0 1.0 -1.0 1.0 -1.0 1.0 $zmin $zmax [alt $k] [az $k]
}
$w cmd plbox3 "bnstu" "x axis" 0.0 0 \
"bnstu" "y axis" 0.0 0 \
"bcdmnstuv" "z axis" 0.0 0
$w cmd plcol0 2
# diffuse light surface plot
if {$ifshade == 0} {
cmap1_init_8 $w 1
$w cmd plsurf3d x y z 0
# magnitude colored plot
} elseif {$ifshade == 1} {
cmap1_init_8 $w 0
# Note: the [expr] command is essential here - plsurf3d doesn't accept
# the hexadecimal form apparently!
$w cmd plsurf3d x y z [expr {$::PLPLOT::MAG_COLOR}]
# magnitude colored plot with faceted squares
} elseif {$ifshade == 2} {
cmap1_init_8 $w 0
$w cmd plsurf3d x y z [expr {$::PLPLOT::MAG_COLOR | $::PLPLOT::FACETED}]
# magnitude colored plot with contours.
} else {
cmap1_init_8 $w 0
$w cmd plsurf3d x y z $xpts $ypts \
[expr {$::PLPLOT::MAG_COLOR | $::PLPLOT::SURF_CONT | $::PLPLOT::BASE_CONT}] clev $nlev
}
}
}
# Restore defaults
# $w cmd plcol0 1
restore_cmap1_8 $w
}
|