; docformat = 'rst' ;+ ; This is an example program to demonstrate how to create additional Y axes for a plot ; with IDL function graphics routines. ; ; :Categories: ; Graphics ; ; :Examples: ; Save the program as "additional_axes_plot_fg.pro" and run it like this:: ; IDL> .RUN additional_axes_plot_fg ; ; :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, 14 January 2014 by David W. Fanning. ; ; :Copyright: ; Copyright (c) 2014, Fanning Software Consulting, Inc. ;- PRO Additional_Axes_Plot_FG, WINDOW=aWindow ; Do this in decomposed color. cgSetColorState, 1, CURRENT=currentColorState ; Create some data. data_1 = cgScaleVector(cgDemodata(17), 0.0, 1.0) data_2 = cgScaleVector(cgDemodata(17), 0.0, 1000.0) data_3 = (Findgen(101)+1) / 5 ; Specify colors. red = cgColor('red7', /Row, /Triple) grn = cgColor('grn7', /Row, /Triple) blu = cgColor('blu7', /Row, /Triple) ; Leave room in the window for three axes. position = [0.15, 0.15, 0.7, 0.820] thick = 2 ; Open a window and return its reference to the user. aWindow = Window(WINDOW_TITLE="Mulitple Axes Plot") ; Add the first set of data and the left axes. Plot1 = Plot(data_1, Color=red, Thick=thick, Position=position, $ Ytitle='Data 1', /Current) ay1 = Plot1['Axis 1'] ay1.Color = red ay3 = Plot1['Axis 3'] ay3.hide = 1 ; Add the second set of data. Turn off the axes. Plot2 = Plot(data_2, /Current, AXIS_STYLE=0, Position=position, $ Color=grn, LineStyle=2, Thick=thick) ; Add the right axis Axis2 = Axis('Y', Location=[(Plot2.xrange)[1], 0, 0], Target=Plot2, TextPos=1, $ Color=grn, Title='Data 2', TickDir=1) ; Add the third set of data. Turn off the axes Plot3 = Plot(data_3, /Current, AXIS_STYLE=0, Position=position, $ Color=blu, LineStyle=1, Thick=thick) ; Add a third axis and make sure this data is scaled accordiningly. xr = Plot3.xrange Axis3 = Axis('Y', Location=[xr[1]+0.25*(xr[1]-xr[0]),0,0], Target=Plot3, TextPos=1, $ Color=blu, Title='Data 3', /Log, TickDir=1) ; Incoming color state. cgSetColorState, currentColorState END ;***************************************************************** ; This main program shows how to call the program and produce ; various types of output. ; Display the plot in a resizeable graphics window. Additional_Axes_Plot_FG, Window=window ; Create a PostScript file. Linestyles are not preserved in IDL 8.2.3 due ; to a bug. Only encapsulated PostScript files can be created. window.save, 'additional_axes_plot_fg.eps' ; Create a PNG file with a width of 600 pixels. Resolution of this ; PNG file is not very good. window.save, 'additional_axes_plot_fg.png', WIDTH=600 ; For better resolution PNG files, make the PNG full-size, then resize it ; with ImageMagick. Requires ImageMagick to be installed. window.save, 'additional_axes_plot_fg_fullsize.png' Spawn, 'convert additional_axes_plot_fg_fullsize.png -resize 600 additional_axes_plot_fg_resized.png' END