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

;  Copyright (c) 2005-2009, ITT Visual Information Solutions. All
;       rights reserved.
; 
; This batch file creates a contour plot in which the image
; data is re-sized to fit the plot window. 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)	

; Before displaying the image, use the CONTOUR command to create
; the appropriate plot window. The plot window must be created
; before re-sizing the image data. Use the NODATA keyword to inhibit
; actually drawing the contour plot.

CONTOUR, new, X, Y, LEVELS = 2750 + FINDGEN(6) * 250., $
     MAX_VALUE = 5000, XSTYLE = 1, YSTYLE = 1, TITLE='Maroon Bells Region', $
     SUBTITLE = '250 meter contours', XTITLE = 'UTM Coordinates (KM)', /NODATA

;Get size of plot window in device pixels.

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

;Desired size of image in pixels.

SX = PX(1) - PX(0) + 1	
SY = PY(1) - PY(0) + 1

; Display the image with its lower-left corner at the origin of the plot 
; window and with its size scaled to fit the plot window.

TVSCL, CONGRID(image, SX, SY), 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, LEVELS = 2750 + FINDGEN(6) * 250., $
     MAX_VALUE = 5000, XSTYLE = 1, YSTYLE = 1, TITLE='Maroon Bells Region', $
     SUBTITLE = '250 meter contours', XTITLE = 'UTM Coordinates (KM)', /NOERASE

