; docformat = 'rst' ;+ ; This is an example program to demonstrate how to create a wavelength/wavenumber plot ; with Coyote Graphics routines. ; ; :Categories: ; Graphics ; ; :Examples: ; Save the program as "wavenumber_plot.pro" and run it like this:: ; IDL> .RUN wavenumber_plot ; ; :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, 26 July 2013 by David W. Fanning. ; ; :Copyright: ; Copyright (c) 2013, Fanning Software Consulting, Inc. ;- FUNCTION WaveNumberFormat, axis, index, value ; A function used to calculate the wavenumber, given the wavelength. wavenum = 1.0d / value ; frequency RETURN, String(wavenum, Format = '(f0.4)') END PRO WaveNumber_Plot ; Create some data. xdata = Findgen(100)+1 xdata = cgScaleVector(xdata, 5.34, 62.3) ; Wavelength between 5.34 cm and 62.3 cm. ydata = Congrid(cgDemoData(17), 100) xwavelengthRange = [5.34, 62.3] ; In centimeters ; Open a window and draw the plot without the top axis. cgDisplay, 600, 450 cgPlot, xdata, ydata, XStyle=9, Position=[0.15, 0.15, 0.9, 0.820], $ XRange=xwavelengthRange, Charsize=1.25, Color='red', Thick=2, $ XTitle = 'Wavelength (cm)', YTitle='Signal Strength' ; Add the top axis. cgAxis, XAxis=1.0, XRange=xwavelengthRange, $ XStyle=1, Charsize=1.25, XTickFormat='WaveNumberFormat' ; I think the spacing of the axis title is wrong if I use the XTitle keyword ; in the above cgAxis command, so I put it on myself here. xlocation = (!X.Window[1] - !X.Window[0]) / 2 + !X.Window[0] ylocation = !Y.Window[1] + 2.75 * (!D.Y_CH_Size / Float(!D.Y_Size)) cgText, xlocation, ylocation, 'WaveNumber (waves/sec)', $ /Normal, Alignment=0.5, Charsize=1.25 END ;***************************************************************** ; This main program shows how to call the program and produce ; various types of output. ; Display the plot in a graphics window. WaveNumber_Plot ; Display the plot in a resizeable graphics window. cgWindow, 'WaveNumber_Plot', WTitle='Wave Number Plot in a Resizeable Graphics Window' ; Create a PostScript file. cgPS_Open, 'wavenumber_plot.ps' WaveNumber_Plot cgPS_Close ; Create a PNG file with a width of 600 pixels. cgPS2Raster, 'wavenumber_plot.ps', /PNG, Width=600 END