Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

Using the AXIS Procedure


The AXIS procedure draws and annotates an axis. It optionally saves the scaling established by the axis for use by subsequent graphics procedures. It can be used to add additional axes to plots or to draw axes at a specified position.

The AXIS procedure accepts the set of plotting keyword parameters that govern the scaling and appearance of the axes. Additionally, the keyword parameters XAXIS, YAXIS, and ZAXIS specify the orientation and position (if no position coordinates are present) of the axis. The value of these parameters are 0 for the bottom or left axis and 1 for the top or right. The tick marks and their annotation extend away from the plot window. For example, specify YAXIS = 1 to draw a y-axis on the right of the window.

The optional keyword parameter SAVE saves the data-scaling parameters established for the axis in the appropriate axis system variable, !X, !Y, or !Z. The call to AXIS is as follows:

AXIS[[, X, Y], Z] 

where X, Y, and optionally Z specify the coordinates of the axis. Any of the coordinate systems can be used by including the appropriate coordinate keyword in the call. The coordinate corresponding to the axis direction is ignored. When specifying an x-axis, the x-coordinate parameter is ignored, but must be present if there is a y coordinate.

Example: The AXIS Procedure

The figure shown below illustrates using AXIS to draw axes with a different scale, opposite the main x- and y-axes. The plot is produced using PLOT with the bottom and left axes annotated and scaled in units of days and degrees Fahrenheit. The XMARGIN and YMARGIN keyword parameters are specified to allow additional room around the plot window for the new axes. The keyword parameters XSTYLE = 8 and YSTYLE = 8 inhibit drawing the top and right axes.

Next, the AXIS procedure is called to draw the top, XAXIS = 1, axis, labeled in months. Eleven tick intervals with 12 tick marks are drawn. The x value of each monthly tick mark is the day of the year that is approximately the middle of the month. Tick-mark names come from the MONTH string array.

The right y-axis, YAXIS = 1, is drawn in the same manner. The new y-axis range is set by converting the original y-axis minimum and maximum values, saved by PLOT in !Y.CRANGE, from Fahrenheit to Celsius, using the formula C = 5(F-32)/9. The keyword parameter YSTYLE = 1 forces the y-axis range to match the given range exactly. The program is as follows:

; Plot the data, omit right and top axes: 
PLOT, DAY, TEMP, /YNOZERO, $ 
   SUBTITLE = 'Denver Average Temperature', $ 
   XTITLE = 'Day of Year', $ 
   YTITLE = 'Degrees Fahrenheit', $ 
   XSTYLE=8, YSTYLE=8, XMARGIN=[8, 8], YMARGIN=[4, 4] 
; Draw the top x-axis, supplying labels, etc. 
; Make the characters smaller so they will fit: 
AXIS, XAXIS=1, XTICKS=11, XTICKV=DAY, XTICKN=MONTH, $ 
   XTITLE='Month', XCHARSIZE = 0.7 
; Draw the right y-axis. Scale the current y-axis minimum 
; values from Fahrenheit to Celsius and make them 
; the new min and max values. Set YSTYLE=1 to make axis exact. 
AXIS, YAXIS=1, YRANGE =  (!Y.CRANGE-32)*5./9., YSTYLE = 1, $ 
   YTITLE = 'Degrees Celsius' 

The code above is included in the batch file plot09 in the examples/doc subdirectory of the IDL distribution.

Using AXIS with Polar Plots

If the POLAR keyword parameter is set, the IDL PLOT procedure converts its coordinates from polar to Cartesian coordinates when plotting. The first parameter to plot is the radius, R, and the second is the angle theta (expressed in radians). Polar plots are produced using the standard axis and label styles, with box axes enclosing the plot area.

The following figure illustrates using AXIS to draw centered axes, dividing the plot window into the four quadrants centered about the origin. This method uses PLOT to plot the polar data and to establish the coordinate scaling, but suppresses the axes. Next, two calls to AXIS add the x- and y-axes, drawn through data coordinate (0, 0).

; Make a radius vector: 
R = FINDGEN(100) 
; Make a vector: 
THETA = R/5 
; Plot the data, suppressing the axes by setting their styles to 4: 
PLOT, R, THETA, SUBTITLE='Polar Plot', XSTY=4, YSTY=4, /POLAR 
AXIS, 0, 0, XAX=0 
; Draw the x and y axes through (0, 0): 
AXIS, 0, 0, YAX=0 

The code above is included in the batch file plot09 in the examples/doc subdirectory of the IDL distribution.


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]