; docformat = 'rst' ;+ ; This is an example program to demontrate how to create a symbol plot ; with Coyote Graphics routines. ; ; Based on a graphics plot found here: http://iopscience.iop.org/1538-3881/138/4/1003/pdf/aj_138_4_1003.pdf. ; ; Data downloaded from AstroPlotLib (http://astroplotlib.stsci.edu/) and renamed. ; ; :Categories: ; Graphics ; ; :Examples: ; Save the program as "symbol_plot.pro" and run it like this:: ; IDL> .RUN symbol_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, 24 January 2013 by David W. Fanning. ; ; :Copyright: ; Copyright (c) 2013, Fanning Software Consulting, Inc. ;- PRO Symbol_Plot ; Read the data file containing the magitudes of the data, collected ; at 3.6 and 4.5 microns, as well as the spectral classification. ; The data is arranged in three columns: 3.6 mag, 4.5 mag, class. filename = 'spectral_class.txt' nrows = File_Lines(filename) OpenR, lun, filename, /Get_Lun data = FltArr(3, nrows) ReadF, lun, data Free_Lun, lun ; Parse the data into vectors. mag36 = Reform(data[0,*]) mag45 = Reform(data[1,*]) class = Reform( Fix(data[2,*]) ) ; Create vectors for plotting. x = mag36 - mag45 y = Temporary(mag36) ; Add a light gray background to the plot. cgDisplay position = [0.125, 0.125, 0.85, 0.9] cgColorFill, Position=position, Color='ivory' ; Set up the plot. Note a second Y axis will be added later. cgPlot, x, y, /NoData, YStyle=8, XStyle=1, XTitle ='[3.6]-[4.5]', $ YTitle='[3.6]', XRange=[-1., 3.2], YRange=[18., 4.], $ Position=position, Charsize=cgDefCharsize()*1.25, /NoErase ; Set up the symbol colors, types, and sizes. symColors = ['grn5', 'blu7', 'magenta', 'dark green', 'red', 'ygb5', 'cornflower blue', 'tg3' ] symTypes = [ 17, 1, 4, 14, 15, 6, 16, 2 ] symSizes = [ 1.5, 1.25, 1.25, 1.25, 1.25, 1.0, 1.25, 0.75 ] symNames = [ 'O', 'Early B','Late B', 'AFG I', 'RSG', 'WR', 'sgB[e]', 'LBV' ] ; Overplot the symbols. FOR j=0,7 DO BEGIN thisClass = Where(class EQ j+1, count) IF count EQ 0 THEN Continue cgOPlot, x[thisClass], y[thisClass], PSYM=symTypes[j], COLOR=symColors[j], SYMSIZE=symSizes[j] ENDFOR ; Add a plot legend. cgLegend, TITLES=symNames, PSYM=symTypes, COLOR=symColors, Location=[2.2, 2.0], $ VSPACE=2.0, /DATA, LENGTH=0.0, /BOX ; Add the final axis. cgAxis, YAxis = 1, YRange=(!Y.CRange-18.41), YStyle=1, YTitle='M$\sub3.6$', $ Charsize=cgDefCharsize()*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. Symbol_Plot ; Display the plot in a resizeable graphics window. cgWindow, 'Symbol_Plot', Background='White', $ WTitle='Symbol Plot in a Resizeable Graphics Window' ; Create a PostScript file. cgPS_Open, 'symbol_plot.ps' Symbol_Plot cgPS_Close ; Create a PNG file with a width of 600 pixels. cgPS2Raster, 'symbol_plot.ps', /PNG, Width=600 END