! Example of a color map with a scale. ! Author: Francois Tonneau ! These are the number of steps we will require for a color gradient. Higher ! numbers result in a smoother gradient at the expense of processing time. ! Decrease x_steps and y_steps if the figure takes too long to appear. x_steps = 250 y_steps = 250 size 13 10 set font ss amove 2 2 begin graph size 6 6 fullsize title "Landscape" hei 0.4 dist 0.5 xaxis min -2 max 2 yaxis min -2 max 2 ticks off labels dist 0.25 xtitle "X" hei 0.4 dist 0.5 ytitle "Y" hei 0.4 dist 0.5 ! When called from within a graph block, the 'colormap' command assumes a ! different, simpler syntax. The first argument is a subroutine that assigns ! a numeric value in the 0-1 range to (x, y) graph coordinates. The second ! and third arguments are the number of steps for x and y, respectively. ! The last argument (the one after the 'palette' keyword) is a custom ! color palette. *The first and last arguments should be non-quoted.* colormap z(x,y) x_steps y_steps palette glow end graph ! Here is the subroutine we use to assign numeric values to (x, y) graph ! coordinates: sub z x y local sigma = 0.75 local value = exp(-(x^2 + y^2)/(2 * sigma^2)) return value end sub ! Our palette subroutine returns a nonlinear mixture (in standard RGB space) of ! three colors as a function of numeric input: sub glow z local r_cool = 0; local g_cool = 78; local b_cool = 88 local r_luke = 205; local g_luke = 205; local b_luke = 205 local r_warm = 205; local g_warm = 92; local b_warm = 92 if z < 0.50 then local w = sqrt(z/0.50) local r = w * r_luke + (1 - w) * r_cool local g = w * g_luke + (1 - w) * g_cool local b = w * b_luke + (1 - w) * b_cool end if if z >= 0.50 then local w = sqrt((z - 0.50)/0.50) local r = w * r_warm + (1 - w) * r_luke local g = w * g_warm + (1 - w) * g_luke local b = w * b_warm + (1 - w) * b_luke end if return rgb255(r, g, b) end sub set hei 0.28 just bl ! We add a custom color scale: height = 2.0 width = 0.6 for z = 0 to 0.9 step 0.1 amove 9.5 height box width width fill glow(z) rmove 0.8 -0.1 write format$(z, "fix 2") height = height + width next z rmove 0 width write "1.00" set hei 0.4 just cc amove 11.5 5 write "Z" ! This script ends our tutorial. Although we have covered a lot of ground, feel ! free to consult the User Manual for the full details on these topics, as well ! as information on other GLE options and commands.