Inform me () when using this script or encorporating it in a library.
Source code of win.pro:
;+
; NAME:
; WIN
; PURPOSE:
; The replacement for !P.MULTI for handling multi-plot pages. It
; is based on the solid SuperMongo routine 'window'. Consecutive
; plots need the /NOERASE. It does *not* handle tick values,
; axis names, etc. This is left to the user.
; CALLING SEQUENCE:
; win, nx, ny, xr, yr[, xg=xg][, yg=yg]
; EXAMPLES:
; win, 5, -6, 1, '2:4'
; Divides the plotting area into 5x6 pieces and uses the
; first column and rows 2 through to 4 (from the bottom) as
; the next plotting region, where there is no space between
; the rows
; plot, x1, y1, xr=range([x1,x2], pct=5)
; Do this plot as the first
; win, 5, -6, '2:5', '2:4'
; plot, x2, y2, xr=range([x1,x2], pct=5), xtickname=REPLICATE(' ', 30), /noerase
; Do the second plot with the same x-axis and ticknames
; suppressed
; win, 1,1,1,1
; Returns everything to normal
; KEYWORDS:
; nx = number of divisions in the x direction. If negative, no
; space between them columns
; ny = number of divisions in the y direction. If negative, no
; space between the rows
; xr = range of columns to span; can be scalar for one column or
; a string to indicate a range
; yr = range of rows to span; can be scalar for one column or a
; string to indicate a range
; xg = sets the xgutter value, i.e. the space between columns; 0
; is none, 1 is standard; can be any value
; xg = sets the xgutter value, i.e. the space between rows; 0
; is none, 1 is standard; can be any value
; MODIFICATION HISTORY:
; Before 05/06/2007 Written by Eduard Westra
;-
PRO win, nx, ny, xr, yr, xg=xg, yg=yg;, force=force
COMMON winPos, winPosition, xgutter, ygutter
IF KEYWORD_SET(winPosition) THEN BEGIN
winPosition = winPosition
ENDIF ELSE BEGIN
winPosition = !P.POSITION
ENDELSE
IF KEYWORD_SET(xg) THEN BEGIN
xgutter = xg
ENDIF ELSE BEGIN
xgutter = (KEYWORD_SET(xgutter) ? xgutter : 1)
ENDELSE
IF KEYWORD_SET(yg) THEN BEGIN
ygutter = yg
ENDIF ELSE BEGIN
ygutter = (KEYWORD_SET(ygutter) ? ygutter : 1)
ENDELSE
;OR N_ELEMENTS(winPosition EQ 0)
IF (nx EQ 1) AND (ny EQ 1) AND (xr EQ 1) AND (yr EQ 1) THEN BEGIN
;IF KEYWORD_SET(force) THEN $
; IF force NE 0 THEN BEGIN
!P.POSITION = [0,0,0,0]
winPosition = [0,0,0,0]
; ENDIF ELSE $
; !P.POSITION = winPosition
xgutter = 1
ygutter = 1
RETURN
ENDIF
rx = STRSPLIT(xr, ':', count=count, /EXTRACT)
CASE count OF
1: BEGIN
xl = MIN(FIX(rx))
xh = MAX(FIX(rx))
END
2: BEGIN
xl = MIN(FIX(rx))
xh = MAX(FIX(rx))
END
ELSE: MESSAGE, 'Invalid x range...'
ENDCASE
ry = STRSPLIT(yr, ':', count=count, /EXTRACT)
CASE count OF
1: BEGIN
yl = MIN(FIX(ry))
yh = MAX(FIX(ry))
END
2: BEGIN
yl = MIN(FIX(ry))
yh = MAX(FIX(ry))
END
ELSE: MESSAGE, 'Invalid y range...'
ENDCASE
IF (xh GT ABS(nx)) THEN MESSAGE, 'X range too high...'
IF (yh GT ABS(ny)) THEN MESSAGE, 'Y range too high...'
IF (xl LE 0) THEN MESSAGE, 'X range too low...'
IF (yl LE 0) THEN MESSAGE, 'Y range too low...'
xborder = (!X.MARGIN*!D.X_CH_SIZE)/!D.X_VSIZE ;!X.MARGIN in normalised units
yborder = (!Y.MARGIN*!D.Y_CH_SIZE)/!D.Y_VSIZE ;!Y.MARGIN in normalised units
wx = (xh - xl) + 1 ;spanning wx columns
wy = (yh - yl) + 1 ;spanning wy rows
dx = (nx EQ 1 OR nx LT 0 ? 0. : TOTAL(xborder)*xgutter)/2. ;in normalised units
dy = (ny EQ 1 OR ny LT 0 ? 0. : TOTAL(yborder)*ygutter)/2. ;in normalised units
xsize = (1. - TOTAL(xborder) - (nx-1)*dx)/ABS(nx) ;size of 1 column
ysize = (1. - TOTAL(yborder) - (ny-1)*dy)/ABS(ny) ;size of 1 column
x1 = xborder[0] + ((xl-1)*(dx+xsize))
y1 = yborder[0] + ((yl-1)*(dy+ysize))
x2 = xborder[0] + (xh*xsize) + (xh-1)*dx
y2 = yborder[0] + (yh*ysize) + (yh-1)*dy
!P.POSITION = [x1, y1, x2, y2]
END