from Numeric import *
from pl import *

XPTS = 35		# Data points in x
YPTS = 46		# Data points in y

opt = [1, 2, 3, 3]

alt = [60.0, 20.0, 60.0, 60.0]

az = [30.0, 60.0, 120.0, 160.0]

title = ["#frPLplot Example 8 - Alt=60, Az=30, Opt=1",
	 "#frPLplot Example 8 - Alt=20, Az=60, Opt=2",
	 "#frPLplot Example 8 - Alt=60, Az=120, Opt=3",
	 "#frPLplot Example 8 - Alt=60, Az=160, Opt=3"]

# main
#
# Does a series of 3-d plots for a given data set, with different
# viewing options in each plot.

def main():

    x = (arrayrange(XPTS) - (XPTS / 2)) / float(XPTS / 2)
    y = (arrayrange(YPTS) - (YPTS / 2)) / float(YPTS / 2)
    x.shape = (-1,1)
    r2 = (x*x) + (y*y)
    x.shape = (-1,)
    z = exp(-r2)*cos((2.0*pi)*sqrt(r2))

    pllightsource(1., 1., 1.)
    #set up gray scale.
    rr = arrayrange(256)
    gg = rr
    bb = rr
    plscmap1(rr, gg, bb)
    
    for k in range(4):
	for ifshade in range(2):
	    pladv(0)
	    plvpor(0.0, 1.0, 0.0, 0.9)
	    plwind(-1.0, 1.0, -0.9, 1.1)
	    plcol0(1)
	    plw3d(1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0,
	    alt[k], az[k])
	    plbox3("bnstu", "x axis", 0.0, 0,
	    "bnstu", "y axis", 0.0, 0,
	    "bcdmnstuv", "z axis", 0.0, 0)
	    
	    plcol0(2)
	    if ifshade == 1:
		plotsh3d(x, y, z, 0)
	    else:
		plot3d(x, y, z, opt[k], 1)
	    plcol0(3)
	    plmtex("t", 1.0, 0.5, 0.5, title[k])

    # Restore defaults
    plcol0(1)
	
main()

@@ -381,16 +381,1025 @@
 pt=3%22%5D%0A%0A
+# Routine for restoring colour map1 to default.%0A# See static void plcmap1_def(void) in plctrl.c for reference.%0Adef restore_cmap1():%0A    # For center control points, pick black or white, whichever is closer to bg %0A    # Be careful to pick just short of top or bottom else hue info is lost%0A    vertex = sum(array(plgcolbg()))/(3.*255.)%0A    if vertex %3C 0.5:%0A%09vertex = 0.01%0A    else:%0A%09vertex = 0.99%0A    # Independent variable of control points.%0A    i = array((0., 0.45, 0.55, 1.))%0A    # Hue for control points.  Blue-violet to red%0A    h = array((260., 260., 0., 0.,))%0A    # Lightness ranging from medium to vertex to medium%0A    l = array((0.5, vertex, vertex, 0.5))%0A    # Saturation is complete for default%0A    s = array((1., 1., 1., 1.,))%0A    # Integer flag array is zero (no interpolation along far-side of colour%0A    # figure%0A    rev = array((0, 0, 0, 0,))%0A    # Default number of cmap1 colours%0A    plscmap1n(128)%0A    # Interpolate between control points to set up default cmap1.%0A    plscmap1l(0, i, h, l, s)%0A%0A
 # main%0A#
@@ -2396,16 +2396,36 @@
 col0(1)%0A
+    restore_cmap1()%0A
 %09%0Amain()

Add routine to restore cmap1 to default (so that subsequent examples that use cmap1 such as xw16 still continue to have default cmap1).