Martin writes:
>
> I have a problem with 2) in that I can't find any IDL routines that do
> this. Does anyone happen to know how to go about this at all? I'd be
> grateful for a any suggestions you might have.
Here is something I just knocked out, called ColorGrid.
It grids an irregular grid, each grid rectangle set
equal to the value of the grid at that location.
Cheers,
David
;*********************************************************** ************
PRO ColorGrid
; Create example data.
x = RandomU(-3L, 20) * 20
x = x[Sort(x)]
y = Indgen(20)
data = BytScl(Dist(20))
; Load colors
LoadCT, 5
; Decomposed color.
IF (!D.Flags AND 256) NE 0 THEN $
Device, Decomposed=0, Get_Decomposed=theState
; Set up the coordinate system.
Plot, x, y, /NoData, XStyle=5, YStyle=5
; Draw polygons.
FOR j=0,N_Elements(x)-2 DO BEGIN
FOR k=0,N_Elements(y)-2 DO BEGIN
Polyfill, [x[j], x[j], x[j+1], x[j+1], x[j]], $
[y[k], y[k+1], y[k+1], y[k], y[k]], $
Color=data[j,k], /Data
ENDFOR
ENDFOR
; Redraw plot.
Plot, x, y, /NoData, /NoErase, XStyle=1, YStyle=1
; Draw grid.
FOR j=1,N_Elements(x)-1 DO $
PLOTS, [x[j], x[j]], [!Y.CRange[0], !Y.CRange[1]]
FOR j=1,N_Elements(y)-1 DO $
PLOTS, [!X.CRange[0], !X.CRange[1]], [y[j], y[j]]
; Clean-up.
IF (!D.Flags AND 256) NE 0 THEN $
Device, Decomposed=theState
END
;*********************************************************** ************
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|