Next: 7.6 Plotting of histograms Up: 7. Cook-book Previous: 7.4 A 3-D perspective Contents Index

#
7.5 A 3-D illuminated surface in black and white

Instead of a mesh plot we may choose to show 3-D surfaces using artificial illumination. For this example we will use grdmath to make a grdfile that contains the surface given by the function , where . The illumination is obtained by passing two grdfiles to grdview: One with the z-values (the surface) and another with intensity values (which should be in the ±1 range). We use grdgradient to compute the horizontal gradients in the direction of the artificial light source. The gray.cpt file only has one line that states that all z values should have the gray level 128. Thus, variations in shade are entirely due to variations in gradients, or illuminations. We choose to illuminate from the SW and view the surface from SE:

    #!/bin/csh
    #        GMT EXAMPLE 05
    #
    #        $Id: job05.csh,v 1.4 2004/04/10 17:19:14 pwessel Exp $
    #
    # Purpose:    Generate grid and show monochrome 3-D perspective
    # GMT progs:    grdgradient, grdmath, grdview, pstext
    # Unix progs:    echo, rm
    #
    grdmath -R-15/15/-15/15 -I0.3 X Y HYPOT DUP 2 MUL PI MUL 8 DIV COS EXCH NEG 10 DIV EXP MUL \
       = sombrero.grd
    echo '-5    128    5    128' >! gray.cpt
    grdgradient sombrero.grd -A225 -Gintensity.grd -Nt0.75
    grdview sombrero.grd -JX6i -JZ2i -B5/5/0.5SEwnZ -N-1/white -Qs -Iintensity.grd -X1.5i -K \
       -Cgray.cpt -R-15/15/-15/15/-1/1 -E120/30 -U/-1.25i/-0.75i/"Example 5 in Cookbook" >! example_05.ps
    echo "4.1 5.5 50 0 33 BC z(r) = cos (2@~p@~r/8) * e@+-r/10@+" | pstext -R0/11/0/8.5 -Jx1i -O \
       >> example_05.ps
    \rm -f gray.cpt sombrero.grd intensity.grd .gmt*

The variations in intensity could be made more dramatic by using grdmath to scale the intensity file before running grdview. For very rough data sets one may improve the smoothness of the intensities by passing the output of grdgradient to grdhisteq. The shell-script above will result in a plot like the one in Figure 7.5.

Figure 7.5: 3-D illuminated surface.

Next: 7.6 Plotting of histograms Up: 7. Cook-book Previous: 7.4 A 3-D perspective Contents Index