|
The option COL (or COLZ which draw the colour map in addition) uses a colour map from the colour indexes 0 to 7 (first 8 colours) if the parameter NCOL is less or equal to 8, or the colour indexes 8 to NCOL if the parameter NCOL is greater than 8. This allows to leave as they are the first 8 basic colours. The parameter NCOL can be changed with the command SET. The following macro illustrate the various cases.
![]() |
Macro Colz
Set * ; Opt * ; H/Del *
*
Fun2 100 1000*(x**2+y**2) 100 -1 1 100 -1 1 ' '
*
Mess ' '
Mess 'The first 8 (0-7) basic colours are used'
Mess ' '
Hist/Plot 100 COLZ
Wait
*
Mess ' '
Mess 'SET NCOL allows to enlarge the colour map and defines'
Mess 'a grey scale ramp from color index 8 to NCOL'
Mess ' '
Set NCOL 20
Hist/Plot 100 COLZ
Wait
*
Mess ' '
Mess 'The command PALETTE defines (by default) a geographical'
Mess 'palette form 8 to NCOL'
Mess ' '
Palette 1
Hist/Plot 100 COLZ
Wait
*
Mess ' '
Mess 'The command COLOR allows to define individually the colours.'
Mess ' '
Color 20 1 0 0
Color 8 1 0 0
Color 15 1 0 0
Hist/Plot 100 COLZ
*
Return
|
![]() |
|
![]() |
|
![]() |
The following example is in fact a tool allowing to define a smooth colour map in a very simple way. This tool consist of 2 COMIS routines which should be saved in the files shade.f and setshd.f. The routine setshd allows to define a set (up to 20) of fixed colours which will be used to define the colour map. Once this set of colours is define, a single call to shade allows to define the colour map. An example is given below, with the macro shade.kumac.
File "shade.f":
subroutine shade()
parameter (nmx = 20)
common /shpt/ npt,idx(nmx),r(nmx),g(nmx),b(nmx)
if (npt.lt.2) then
print*, 'Error: at least two colours are needed'
return
endif
do i=2,npt
j = i-1
i1 = idx(j)
i2 = idx(i)
r1 = r(j)
g1 = g(j)
b1 = b(j)
r2 = r(i)
g2 = g(i)
b2 = b(i)
n = i2-i1+1
do ii=i1,i2
scale = float(ii-i1)/(n-1)
rs = (r2 - r1)*scale + r1
gs = (g2 - g1)*scale + g1
bs = (b2 - b1)*scale + b1
call iscr(1,ii,rs,gs,bs)
enddo
enddo
end
File "setshd.f":
subroutine setshd(idxi, ri, gi, bi)
parameter (nmx = 20)
common /shpt/ npt,idx(nmx),r(nmx),g(nmx),b(nmx)
if (idxi.lt.0) then
npt = 0
return
endif
npt = npt+1
if (npt.gt.nmx) then
print*, 'Error: too many colours'
return
endif
idx(npt) = idxi
r(npt) = ri
g(npt) = gi
b(npt) = bi
end
File "shade.kumac":
Macro shade
set ncol 255
fun2 100 exp(-.5*((x-75)/10)**2)*exp(-.5*((y-60)/10)**2) 100 45 105 100 30 90 ' '
call setshd.f( -1,0.0,0.0,0.0)
call setshd.f( 8,0.0,0.0,1.0)
call setshd.f(100,1.0,0.0,0.0)
call setshd.f(130,1.0,1.0,0.0)
call setshd.f(180,0.0,1.0,0.5)
call setshd.f(255,1.0,0.6,0.5)
call shade.f
h/pl 100 colz
h/del 100
return
Just do:
PAW > Exec shade
and you will get the following picture:
The two following files give an other example showing how to use the option COLZ with a defined colour table. This example is an extension of the previous one. It allows to define the colors in histogram Z coordinates (those visible on the COLZ plot).
File "colz.kumac":
Macro Colz
Opt * ; h/del * ; v/del *
fun2 2 sin(x)/x*cos(y)*y 100 -6 6 100 -6 6 ' '
N = 6
V/create Z([N]) R -12 -4 -1 0 1 12
V/create R([N]) R 1.0 1.0 0.0 1.0 0.0 0.0
V/create G([N]) R 0.0 1.0 1.0 1.0 1.0 0.0
V/create B([N]) R 0.0 0.0 1.0 1.0 0.0 1.0
call colz.f(2,255,[N],Z,R,G,B)
Return
File "colz.f":
Subroutine Colz(Id,Ncol,N,Z,R,G,B)
*
* This procedure defines a mapping of a 2D histogram content to a palette
* of colours defines by R G B values. Ncol is the number of colours in the
* colour map.
* Z(i) is mapped to R(i), G(i), B(i).
* If Z(1) < Zmin, Zmin is used, is Z(N) > Zmax Z max is used
*
Dimension Z(N),R(N),G(N),B(N)
Character*32 Chtitl
*
Call Hgive(Id,Chtitl,Ncx,Xmin,Xmax,Ncy,Ymin,Ymax,Nwt,Loc)
*
Call Igset('NCOL',Float(Ncol))
*
Zmin = Hij(Id,1,1)
Zmax = Zmin
Do j=1,Ncy
Do I=1,Ncx
Zi = Hij(Id,i,j)
If (Zi.Gt.Zmax) Zmax = Zi
If (Zi.Lt.Zmin) Zmin = Zi
Enddo
Enddo
Dz = Zmax-Zmin
*
Call Setshd( -1,0.0,0.0,0.0)
Do I=1,N
Zi = Z(I)
If (Zi.Lt.Zmin) Zi = Zmin
If (Zi.Gt.Zmax) Zi = Zmax
Idz = Int(((Zi-Zmin)/Dz)*(Ncol-8)+8)
Call Setshd(Idz,R(I),G(I),B(I))
Enddo
Call Shade
Call Hplot(Id,'COLZ',' ',0)
End
*.__________________________________
*
Subroutine Shade()
Parameter (Nmx = 20)
Common /SHPT/ Npt,Idx(Nmx),R(Nmx),G(Nmx),B(Nmx)
If (Npt.Lt.2) Then
Print*, 'Error: at least two colours are needed'
Return
Endif
Do I=2,Npt
J = I-1
I1 = Idx(j)
I2 = Idx(i)
R1 = R(j)
G1 = G(j)
B1 = B(j)
R2 = R(i)
G2 = G(i)
B2 = B(i)
n = i2-i1+1
Do Ii=I1,i2
Scale = Float(Ii-I1)/(N-1)
Rs = (R2 - R1)*Scale + R1
Gs = (G2 - G1)*Scale + G1
Bs = (B2 - B1)*Scale + B1
Call Iscr(1,Ii,Rs,Gs,Bs)
Enddo
Enddo
End
*.__________________________________
*
Subroutine Setshd(Idxi, Ri, Gi, Bi)
Parameter (Nmx = 20)
Common /SHPT/ Npt,Idx(Nmx),R(Nmx),G(Nmx),B(Nmx)
If (Idxi.Lt.0) Then
Npt = 0
Return
Endif
Npt = Npt+1
If (Npt.Gt.Nmx) Then
Print*, 'Error: too many colours'
Return
Endif
Idx(Npt) = Idxi
R(Npt) = Ri
G(Npt) = Gi
B(Npt) = Bi
End
Just do:
PAW > Exec colz
and you will get the following picture:
![]() | Release Notes | Known bugs | FAQs | Contributions | Tutorial | Reference manual | Down load | Miscellaneous |