|
Getting Started with IDL: 2-D Plots |
|
Simple plots can be charted using the PLOT procedure. Each call to PLOT establishes the plot window (the rectangular area enclosed by the axis), the plot region (the box enclosing the plot window and its annotation), the axis types (linear or logarithmic), and the scaling.
First, we'll plot a simple graph using a sine function. Use the FINDGEN function here to specify the dimensions of the array. The FINDGEN function returns a single-precision, floating-point array, with the specified dimension, where each element of the array is set to the value of its one-dimensional subscript.
X= 2*!PI/100 * FINDGEN(100)
Also, additional data can be added, as before, using the OPLOT procedure. Frequently, the color index, linestyle, or line thickness parameters are changed in each call to OPLOT to distinguish the data sets. The IDL Reference Guide contains a table describing the features you can change.
Now use OPLOT to plot the new information over the existing plot:
OPLOT, SIN(2*X)
OPLOT, SIN(3*X)
The results are shown in the following figure.
![]() |
IDL allows you to easily print the plot just created. Simply enter the following command lines shown.
MYDEVICE=!D.NAME
SET_PLOT, 'printer'
PLOT, SIN(X)
DEVICE, /CLOSE
SET_PLOT, MYDEVICE
| Note If you are having problems printing on UNIX, be sure your printer is configured correctly. For more information on this see IDL Printer Setup in UNIX or Mac OS X. |
IDL Online Help (March 06, 2007)