(5) A 3-D illuminated surface (in bw)
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 grid file that contains the surface given by the function \(z(x, y) = \cos (2\pi r/8)\cdot e^{-r/10}\), where \(r^2 = (x^2 + y^2)\). The illumination is obtained by passing the grid file to grdview and requesting that artificial shading be derived from the horizontal gradients in the direction of the artificial light source (set by -I). The makecpt command creates a simple color scheme for a constant gray level of 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:
#!/usr/bin/env bash
# GMT EXAMPLE 05
#
# Purpose: Generate grid and show monochrome 3-D perspective
# GMT modules: grdmath, grdview, text, makecpt
# Unix progs: rm
#
gmt begin ex05
gmt 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.nc
gmt makecpt -C128 -T-5/5 -N
gmt grdview sombrero.nc -JX12c -JZ4c -B -Bz0.5 -BSEwnZ+t"z(r) = cos (2@~p@~r/8) @~\327@~e@+-r/10@+" -N-1+gwhite -Qs \
-I+a225+nt0.75 -C -R-15/15/-15/15/-1/1 -p120/30 --FONT_TITLE=50p,ZapfChancery-MediumItalic --MAP_TITLE_OFFSET=-1c
rm -f sombrero.nc
gmt end show
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 computing them first with grdgradient and then pass them to grdhisteq. The shell-script above will result in a plot like the one in Figure.