Color Maps, False Color Images
None
colormap.gle
colormap.gle
! 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.
colormapcontour.gle
colormapcontour.gle
! Example of how to use color map and contour at the same time.
! Plot of modelling results coming from Abaqus.
! By Fabien Leonard.
size 12 12
set font texcmr
include "color.gle"
include "contour.gle"
! creates the z-value file to be used by the contour command
begin fitz
data "Zstress.csv"
x from 0 to 2 step 0.1
y from 0 to 2 step 0.1
ncontour 6
end fitz
begin contour
data "Zstress.z"
values from 100 to 800 step 100
end contour
begin graph
title "Modelling results of specimen stress (in MPa)"
xtitle "Bolt shortening (mm)"
ytitle "Step"
xticks color white
yticks color white
colormap "Zstress.z" 500 500 color
data "Zstress-cdata.dat"
d1 line color white lwidth 0.02
end graph
amove xg(xgmax)+0.5 yg(ygmin)
color_range_vertical zmin 0 zmax 815 zstep 50 pixels 1500 format "fix 0"
contour_labels file "Zstress-clabels.dat" format "fix 0"
informationgain.gle
informationgain.gle
size 10 8
include "color.gle"
set font texcmr
tpos = 50; tneg = 50
tot = tpos + tneg
sub entropy p
if (p = 0) or (p = 1) then return 0
else return -p*log(p)/log(2) - (1-p)*log(1-p)/log(2)
end sub
sub information_gain lpos lneg
local rpos = tpos - lpos
local rneg = tneg - lneg
local ltot = lpos + lneg
local rtot = rpos + rneg
return entropy(tpos/tot) - &
ltot/tot*entropy(sdiv(lpos,ltot)) - rtot/tot*entropy(sdiv(rpos,rtot))
end sub
begin graph
xaxis min 0 max tpos
yaxis min 0 max tneg
title "Information Gain"
xtitle "# positives in left branch"
ytitle "# negatives in left branch"
colormap information_gain(x,y) 250 250 color
end graph
set hei 0.29
amove xg(xgmax)+0.3 yg(ygmin)
color_range_vertical zmin 0 zmax 1 zstep 0.1 pixels 500 format "fix 1"
maungazoom.gle
maungazoom.gle
size 16 8
include "color.gle"
! draw left graph
amove 0 0
begin graph
size 8 8
title "Auckland's Maunga Whau Volcano"
colormap "volcano.z" 100 100 palette palette_blue_white_red
end graph
! define zoom rectangle on left graph
zx0 = 1; zy0 = 4
zx1 = 8; zy1 = 12
! draw zoom rectangle in yellow
gsave
set color yellow lwidth 0.1
amove xg(zx0) yg(zy0)
box xg(zx1)-xg(zx0) yg(zy1)-yg(zy0)
grestore
! draw right graph
amove 7 0
begin graph
size 8 8
title "Zoom on ("+num$(zx0)+","+num$(zy0)+") x ("+num$(zx1)+","+num$(zy1)+")"
xaxis min zx0 max zx1
yaxis min zy0 max zy1
colormap "volcano.z" 100 100 palette palette_blue_white_red
end graph
! draw vertical color range
amove 14.5 yg(ygmin)
color_range_vertical zmin 0 zmax 180 zstep 20 palette palette_blue_white_red
polenja.gle
polenja.gle
size 18 19
include "color.gle"
set lwidth .02 hei .7 font texcmr
imax = 0; imaxc = 0
dpsi = 2.5; dphi = 2.5
! dpsi = stepwidth in psi direction, i.e. angle of latitude or elevation;
! dphi = stepwidth in phi direction, i.e. angle of longitude or azimuth.
file$ = "serguei2.nja"
! open result file with three rows: psi phi intensity
! first open to find overall maximum intensity = imax
! and maximum intensity at center = imaxc (i.e. for psi=0)
fopen file$ inchan read
until feof(inchan)
fread inchan psi phi i
if i>imax then
imax = i
end if
if psi=0 then
if i>imaxc then
imaxc = i
end if
end if
next
fclose inchan
! now open result file for actual plotting
! colors are defined with rgb color scheme:
! rgb(0,0,1) (i.e. blue) corresponds to i=0
! rgb(1,0,0) (i.e. red) corresponds to i=max
fopen file$ inchan read
until feof(inchan)
fread inchan psi phi i
amove 8.2 8.2
if psi=0 then
circle dphi fill cvtrgb(imaxc/imax,0,1-imaxc/imax)
else
begin path fill cvtrgb(i/imax,0,1-i/imax)
arc 8*sin(torad(psi+dpsi/2))/(1+cos(torad(psi+dpsi/2))) phi-dphi/2 phi+dphi/2
narc 8*sin(torad(psi-dpsi/2))/(1+cos(torad(psi-dpsi/2))) phi+dphi/2 phi-dphi/2
end path
end if
next
fclose inchan
! labeling
circle 8
for c = 0 to 3
begin rotate c*90
rmove 8 0
rline 0.2 0
end rotate
next c
rmove 8.2 0
set just lc
write "\varphi =0\movexy{-.15}{0}\char{23}"
rmove -8.2 8.2
set just bc
write "\varphi =90\movexy{-.15}{0}\char{23}"
amove 8.2-5 17.5
begin name range
colormap "x" 0 1 0 1 100 1 10 1 palette palette_blue_purple_red
end name
amove pointx(range.lc)-0.1 pointy(range.lc)
set just rc
write "I = 0"
amove pointx(range.rc)+0.1 pointy(range.rc)
set just lc
write "I = max."