pro ColorBox, X,Y,Xthick,Ythick,Color, black=BLACK @compile_opt.pro ; On error return to caller ;+ ; NAME: ; ColorBox ; PURPOSE: ; Color 2D array of boxes of specified size in specified colors ; CALLING SEQUENCE: ; ColorBox, X,Y,Color,Xthick,Ythick, /black ; INPUTS: ; X,Y arrays coordinates of lower-left corner of boxes ; Xthick array/scalar box width in horizontal direction ; Ythick array/scalar box width in vertical direction ; Color 2D array array of color indices ; Black scalar if set and nonzero boxes with color index 0 ; are explicitly colored (by default they are ; skipped) ; CALLS: ; polyfill ; RESTRICTIONS: ; > If Xthick is an array it must have the same dimension as X ; > If Ythick is an array it must have the same dimension as Y ; PROCEDURE: ; > If Xthick is a scalar then the horizontal box width is the same for ; all boxes. Idem for Ythick. ; > If Xthick or Ythick are input as zero, widths are calculated from the ; X and Y arrays respectively ; MODIFICATION HISTORY: ; 1992, Tom Davidson (UCSD) ;- black = keyword_set(black) Nx = n_elements (X) Ny = n_elements (Y) if n_elements(Xthick) eq 1 then if Xthick eq 0 then begin message, /info, 'Automatic determination horizontal box sizes Xthick = shift(X,-1)-X & Xthick(Nx-1) = X(Nx-1)-X(Nx-2) endif if n_elements(Ythick) eq 1 then if Ythick eq 0 then begin message, /info, 'Automatic determination vertical box sizes Ythick = shift(Y,-1)-X & Ythick(Ny-1) = Y(Ny-1)-Y(NY-2) endif I = n_elements (Xthick) if I ne 1 and I ne Nx then message, 'Xthick must be scalar or same size as X' I = n_elements (Ythick) if I ne 1 and I ne Ny then message, 'Ythick must be scalar or same size as Y' Array = Nx ne 1 or Ny ne 1 Col = Color & Xth = Xthick & Yth = Ythick if Array then begin if n_elements (Col) eq 1 then Col = replicate ( Col, Nx , Ny ) if n_elements (Xth) eq 1 then Xth = replicate ( Xth, Nx ) if n_elements (Yth) eq 1 then Yth = replicate ( Yth, Ny ) endif for J=0,Nx-1 do begin for I=0,Ny-1 do begin if Col[J,I] ne 0 or BLACK then begin XJ = X[J] & XJt = XJ+Xth[J] YI = Y[I] & YIt = YI+Yth[I] polyfill, [XJ,XJ,XJt,XJt],[YI,YIt,YIt,YI],color=Col[J,I] endif endfor endfor return & end