PRO Compare_Contour_Plots ; Restore the NCEP temperature data. Restore, 'air.nc.data.sav' ; lat, lon, data ; House keeping tasks. Used for all three examples xrange = [Min(lon), Max(lon)] yrange = [Min(lat), Max(lat)] center_lon = (xrange[1]-xrange[0])/2.0 + xrange[0] nlevels = 12 levels = cgConLevels(Float(data), NLevels=nlevels+1, $ MinValue=Floor(Min(data)), STEP=step, Factor=1) mylat = 40.6 ; Latitude of Fort Collins, Colorado. mylon = 254.9 ; Longitude of Fort Collins, Colorado. LoadCT, 0 cgLoadCT, 2, /Reverse, /Brewer, NColors=nlevels-1, Bottom=1 TVLCT, cgColor('white', /Triple), nlevels ;;;;;;;;;;;;;;;;;;;;; Direct Graphics Example ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Set up start time for rendering speed. startTime = Systime(1) ; Set up the direct graphics map projection. Window, 2, Title='Direct Graphics Contour Plot' ; Must do this in index color. Device, Decomposed=0 ; Set up the map projection. Map_Set, /Cylindrical, 0, 180, Position=[0.1, 0.1, 0.9, 0.8], $ Limit=[Min(lat), Min(lon), Max(lat), Max(lon)] ; Draw the contour plot. Contour, data, lon, lat, /Cell_Fill, /Overplot, $ C_Colors=Indgen(nlevels)+1, Levels=levels Contour, data, lon, lat, /Overplot, $ Color=cgColor('white'), Levels=levels, C_Labels=Replicate(1, 12) ; Add map annotations. Map_Grid, Color=cgColor('charcoal') Map_Grid, /Box, /No_Grid, Color=cgColor('white') Map_Continents, color=cgcolor('tomato') PlotS, mylon, mylat, PSYM=2, SymSize=2, color=cgColor('tg1') cgColorbar, Range=[Min(levels), Max(levels)-step], OOB_High=nlevels, $ NColors=nlevels-1, Bottom=1, /Discrete, Color='opposite', $ Title='Temperature ' + cgSymbol('deg') + 'K', $ Position=[0.1, 0.91, 0.9, 0.95] Device, Decomposed =1 ; Print, the rendering time. Print, 'Direct Graphics Rendering Speed (Seconds): ', systime(1) - startTime ;;;;;;;;;;;;;;;;;;;;; Coyote Graphics Example ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Set up start time for rendering speed. startTime = Systime(1) ; Set up the Coyote Graphics resizeable graphics window. cgWindow, WTitle='Coyote Graphics Contour Plot' cgControl, Execute=0 ; Set up the map projection. map = Obj_New('cgMap', 'Equirectangular', Ellipsoid=19, $ XRange=xrange, YRange=yrange, /LatLon_Ranges, CENTER_LON=center_lon, $ Position=[0.1, 0.1, 0.9, 0.8], Limit=[Min(lat), Min(lon), Max(lat), Max(lon)]) map -> AddCmd, Method='Erase' map -> AddCmd, Method='Draw' ; Draw the contour plot. cgContour, data, lon, lat, /Cell_Fill, /Overplot, /Outline, $ C_Colors=Indgen(nlevels)+1, Levels=levels, Map=map, OutColor='White', /AddCmd ; Add map annotations. cgMap_Grid, Map=map, /Box, /AddCmd cgMap_Continents, Map=map, Color='tomato', /AddCmd cgColorbar, Range=[Min(levels), Max(levels)-step], OOB_High=nlevels, $ NColors=nlevels-1, Bottom=1, /Discrete, $ Title='Temperature ' + cgSymbol('deg') + 'K', $ Position=[0.1, 0.91, 0.9, 0.95], /AddCmd cgPlots, mylon, mylat, PSYM=16, SymSize=2, color='tg1', Map_Object=map, /AddCmd cgControl, Execute=1 ; Print, the rendering time. Print, 'Coyote Graphics Rendering Speed (Seconds): ', systime(1) - startTime ;;;;;;;;;;;;;;;;;;;;; Function Graphics Example ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Set up start time for rendering speed. startTime = Systime(1) ; Load the colors you want to use. cgLoadCT, 2, /Brewer, /Reverse TVLCT, rgb, /Get ; Display the data and disable updates for speed. win = Window(Dimension=[640, 512]) win.Refresh, /Disable ; Create the contour overplot lines. Must do this first to get ; font size correct. overplot = Contour(data, lon, lat, C_Color='gray', $ C_Label_Show=Replicate(1, 12), C_Use_Label_Orientation=1, $ Grid_Units=2, Map_Projection='Equirectangular', Font_Size=8, $ Position=[0.05,0.05,0.95,0.80], RGB_Table=rgb, /Current, $ C_Label_Interval=0.8, C_VALUE=levels) ; Change the map projection properties. map = overplot.MapProjection map.center_longitude = 180.0 ; Change map grid properties grid = map.MapGrid grid.hide = 1 ; Create the filled contour plot, and move the contour lines to the front. dataObj = Contour(data, lon, lat, /Fill, $ Grid_Units=2, Map_Projection='Equirectangular', $ Position=[0.05,0.05,0.95,0.80], RGB_Table=rgb, /Current, $ C_VALUE=levels, RGB_INDICES=BytScl(Indgen(nlevels))) overplot.order, /Bring_Forward ; Change map projection properties. map = dataObj.MapProjection map.center_longitude = 180.0 ; Change map grid properties grid = map.MapGrid grid.color = cgColor('dark gray', /Triple, /Row) grid.linestyle = 1 grid.grid_longitude = 60 grid.grid_latitude = 30 grid.label_position = 0.0 grid.box_axes = 1 ; Add continental outlines. c = MapContinents(Color=cgColor('tomato', /Triple, /Row), /Current) ; Create a color bar for the image. I don't know how to align ; the color bar values with the contour plot levels. fakeObj = Contour(Scale_Vector(data, Min(levels), Max(levels)), lon, lat, /Fill, $ Grid_Units=2, Map_Projection='Equirectangular', $ Position=[0.05,0.05,0.95,0.80], RGB_Table=rgb, /Current, $ C_VALUE=levels, Hide=1) cb = Colorbar(Target=fakeObj, Tickname=levels[0:nlevels], $ Major=13, /Border_On, Title='Temperature $\deg$ K', $ Position=[0.1, 0.88, 0.9, 0.93], Minor=0) s = Symbol(mylon, mylat, 'Star', /Sym_Filled, Sym_Color='red', /Current) ; Update the window. win.Refresh ; Print, the rendering time. Print, 'Function Graphics Rendering Speed (Seconds): ', systime(1) - startTime END