Sample IDL Code to Get You Going
Many thanks to Mark Kramer for writing and sharing this

    Below is some sample IDL code for you to run.  Experiment with different parameters and commands to  better understand how IDL works.  Any line with a ; before it is referred to as "commented out": IDL sees the colon and stops reading until the next line, so you can write commentary or further instructions.  This is also a useful feature if you have some code you're not sure you want or need but don't want to get rid of yet.
    To utilize this, copy everything below the line of asterisks to an editor window in IDL (hooray for multi-tasking!) and run it.  If you want to access it from Unix, it is currently saved on the physics server at /d2/140sp/analysis/IDL_Mark/webpage.pro (you'll have to change the procedure name so it matches the filename) but may not be there by the time you are reading this.
;*******************************************************************************
pro testPS
;the below code writes a tvscl image over an axis plot and saves the output as a
;postscript file
;note. The ps file will be two pages.  I cannot figure out how to fix this yet.
; To see the next page, open the image and hit 'p' if using xv

loadct,34  ;load the color table

set_plot, 'ps'     ;set the device to ps file
device, FILENAME='simpleP.ps', /color  ;set the name of the ps file,
      ;set the file to be in color

n = findgen(100)    ;make some data
r = findgen(100)
t = r # n

contour, t, title='in xv, hit p for next page' ;plot a contour of t, with instructional title
      ;contour requites a two dimensional array
      ;so t must be used, but this does not matter
      ;since n, r, and t all have the same defaut plot layout size
      ;although we only need the clip from this graph
      ;the graph is still useful, since it shows a contour of 't'

afit=!p.clip     ;get the proper clip
erase      ;then erase this graph

plot, t, title='hello', xtitle='x', ytitle='y', xrange=[0,1], yrange=[0,10]
      ;plot the axis and labels
      ;this plot has the same corner aspects
      ;that were found in the !p.clip
      ;Apparently the default size of a plot or contour is
      ;the same, so replacing 't' with 'n' or 'r' would give
      ;the same results.  This is true, since we are only
      ;using the plot for the axises marks, and labels -
      ;we do not care about what is being plotted here.

tvscl, t, afit(0), afit(1), xsize=afit(2) - afit(0), ysize=afit(3) - afit(1);, /centimeters
      ;fit the tvscl into the plot of 't' size using
      ;the !p.clip.  Place the image in the proper x,y
      ;coord and stetch it to fit over the plot of t above
 
device, /close     ;close this file
set_plot, 'x'     ;set the device back to the x window

end
;****************************************************************************

Take me Home    I want to go home!
 
 
 

Last Updated June 1998