;  $Id: //depot/idl/IDL_71/idldir/examples/doc/plot/cntour05#1 $

;  Copyright (c) 2005-2009, ITT Visual Information Solutions. All
;       rights reserved.
; 
; This batch file creates a contour plot that is sized to match
; the image data. This example is from Chapter 11, "Plotting
; Multi-dimensional Arrays", of _Using IDL_.

; Restore variables elev, X, and Y.

@cntour01

; REBIN down to a 70 x 90 matrix.

new = REBIN(elev, 350/5, 450/5) 

; Scale image intensities.

image = BYTSCL(elev, MIN=2658, MAX=4241) 

; Get the size of the image.

SZ = SIZE(image)

; Create a graphics window sized slightly larger than the image

WINDOW, /FREE, XSIZE=SZ[1]+100, YSIZE=SZ[2]+100

; Set up plotting coordinates, but do not draw the contour \
; or axes yet

CONTOUR, new, X, Y, XSTYLE = 4, YSTYLE = 4, /NODATA, /DEVICE

; Get size of plotting window in device pixels. Add an
; extra margin on the bottom to allow for the subtitle

PX = !X.WINDOW * !D.X_VSIZE 
PY = !Y.WINDOW * !D.Y_VSIZE +!Y.MARGIN*4

; Draw the image

TVSCL, image, PX[0], PY[0]

; Write the contours over the image, being sure to use 
; the exact axis styles so that the contours fill the plot 
; window. Inhibit erasing.

CONTOUR, new, X, Y, XSTYLE = 1, YSTYLE = 1, $
   POSITION = [PX[0], PY[0], PX[0]+SZ[1]-1, PY[0]+SZ[2]-1], $
   LEVELS = 2750 + FINDGEN(6) * 250., $ MAX_VALUE = 5000, $
   TITLE='Maroon Bells Region', SUBTITLE = '250 meter contours', $
   XTITLE = 'UTM Coordinates (KM)', /NOERASE, /DEVICE


