Inform me () when using this script or encorporating it in a library.
Source code of range.pro:
;+
; NAME:
; RANGE
; PURPOSE:
; Returns a range encompassing all values of an array and a
; certain percentage of the difference between the minimum and
; maximum value of the array, which is ideal for plotting
; purposes
; CALLING SEQUENCE:
; RANGE, array, pct=pct
; EXAMPLES:
; plot, x, y, xrange=range(x, pct=5), /xr
; KEYWORDS:
; array = input array
; pct = percentage of difference between minimum and maximum
; value to extend the range with. If 0 then range is exactly
; minmax.
; MODIFICATION HISTORY:
; Before 05/06/2007 Written by Eduard Westra
; 12/12/2007 Return a non-zero range when the input has the same
; number everywhere
;-
FUNCTION range, array, pct=pct
IF N_ELEMENTS(pct) NE 1 THEN lpct = 0.d ELSE lpct = pct/100.d
idx = WHERE(FINITE(array) EQ 1)
mm = minmax(array[idx])
d = (diff(mm) EQ 0 ? mm[0] : mm[1]-mm[0])
RETURN, lpct*[-d, d] + mm
END