; docformat = 'rst' ;+ ; This is an example program to demonstrate how to create a rotated histogram plot with logarithmic bins ; with Coyote Graphics routines. ; ; :Categories: ; Graphics ; ; :Examples: ; Save the program as "log_histogram_plot.pro" and run it like this:: ; IDL> .RUN log_histogram_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, 23 January 2013 by David W. Fanning. ; ; :Copyright: ; Copyright (c) 2013, Fanning Software Consulting, Inc. ;- PRO Log_Histogram_Plot ; Set up variables for the plot. Normally, these values would be ; passed into the program as positional and keyword parameters. ; In this example we are interested in the ratio of two vectors. ; Theoretically, the ratio should be equaly distributed in the range ; 0 to 1, and in the range 1 to infinity. We are going to check on ; this with a histogram plot. v1 = Randomu(-3L, 1000) * 100 v2 = Randomu(-5L, 1000) * 100 ; Calculate the ratio of the two random vectors. ratio = v1 / v2 ; Set up the logarithmic bins. bins = [0, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0] ; The secret here is to use Value_Locate to partition the data ; into the bins. binnedRatio = Value_Locate(bins, ratio) ; Now display the histogram of the data. cgDisplay cgHistoplot, binnedRatio, YTickformat='(A1)', /Fill, /Rotate, \$ DataColor='navy', Position=[0.15, 0.125, 0.9, 0.9] labels = ['0', '0.01', '0.1', '1', '10', '100', '1000'] FOR j=0,6 DO cgText, -30, j, labels[j], Alignment=0.5 ; Add an axis label cgText, 0.05, 0.5, /Normal, 'Logarithmic Bins', Orientation=90, \$ Alignment=0.5, Charsize=cgDefCharsize() END ;***************************************************************** ; This main program shows how to call the program and produce ; various types of output. ; Display the plot in a graphics window. Log_Histogram_Plot ; Display the plot in a resizeable graphics window. cgWindow, 'Log_Histogram_Plot', WBackground='white', \$ WTitle='Log Histogram Plot in a Resizeable Graphics Window' ; Create a PostScript file. cgPS_Open, 'log_histogram_plot.ps' Log_Histogram_Plot cgPS_Close ; Create a PNG file with a width of 600 pixels. cgPS2Raster, 'log_histogram_plot.ps', /PNG, Width=600 END