; docformat = 'rst' ;+ ; This is an example program to demontrate how to create a filled contour plot ; that contains missing data with Coyote Graphics routines. ; ; :Categories: ; Graphics ; ; :Examples: ; Save the program as "filled_contour_missing.pro" and run it like this:: ; IDL> .RUN filled_contour_missing ; ; :Author: ; FANNING SOFTWARE CONSULTING:: ; David W. Fanning ; 1645 Sheely Drive ; Fort Collins, CO 80526 USA ; Phone: 970-221-0438 ; E-mail: david@idlcoyote.com ; Coyote's Guide to IDL Programming: http://www.idlcoyote.com ; ; :History: ; Change History:: ; Written, 15 February 2014 by David W. Fanning. ; ; :Copyright: ; Copyright (c) 2014, Fanning Software Consulting, Inc. ;- PRO Filled_Contour_Missing ; Example Gaussian data. Make sure data is floating point array! data = cgDemoData(26) dims = Size(data, /Dimensions) ; Create 25 random missing data points, plus a few larger gaps missingIndices = RandomU(-3L, 25) * dims[0] * dims[1] data[missingIndices] = !Values.F_NaN data[18:45,40:50] = !Values.F_NaN data[75:78, 20:40] = !Values.F_NaN ; Set up variables for the contour plot. Normally, these values ; would be passed into the program as positional and keyword parameters. minValue = Floor(Min(data, /NaN)) maxValue = Ceil(Max(data, /NaN)) nLevels = 10 xtitle = 'X Axis' ytitle = 'Y Axis' position = [0.125, 0.125, 0.9, 0.800] cbposition = [0.125, 0.865, 0.9, 0.895] cbTitle = 'Data Value' ; Set up a "window" for the plot. The PostScript output will have ; the same aspect ratio as the graphics window on the display. cgDisplay, 600, 500, Title='Filled Contour with Missing Data' ; Set up colors for contour plot. cgLoadCT, 33, NColors=nlevels, Bottom=1, CLIP=[30,255] ; Draw the filled contour plot. Absolutely ESSENTIAL to use CELL_FILL instead of FILL keyword. contourLevels = cgConLevels(data, NLevels=10, MinValue=minValue) cgContour, data, /Cell_Fill, Levels=contourLevels, C_Colors=Bindgen(nLevels)+1B, $ /OutLine, Position=position, XTitle=xtitle, YTitle=ytitle ; Draw the color bar. cgColorbar, NColors=nlevels, Bottom=1, Position=cbposition, $ Range=[MinValue, MaxValue], Divisions=nlevels, /Discrete, $ Title=cbTitle, TLocation='Top' END ;***************************************************************** ; This main program shows how to call the program and produce ; various types of output. ; Display the contour plot in a graphics window. Filled_Contour_Missing ; Display the contour plot in a resizeable graphics window. cgWindow, 'Filled_Contour_Missing', WXSize=600, WYSize=500, $ WTitle='Filled Contour Plot with Missing Data' ; Create a PostScript file. cgPS_Open, 'filled_contour_missing.ps' Filled_Contour_Missing cgPS_Close ; Create a PNG file with a width of 600 pixels. cgPS2Raster, 'filled_contour_missing.ps', /PNG, Width=600 END