Chapter Contents

Previous

Next
The GPLOT Procedure

Example 9: Plotting with Different Scales of Values


Procedure features:
PLOT statement options:
HAXIS=
HMINOR=
PLOT and PLOT2 statement options:
CAXIS=
VAXIS=
VMINOR=
Other features:
AXIS statement
SYMBOL statement
Sample library member: GR21N09

[IMAGE]

This example shows how a PLOT2 statement generates a right axis that displays the values of the vertical coordinates in a different scale from the scale that is used for the left axis.

In this plot of the average monthly temperature for Minneapolis, temperature variables that represent degrees centigrade (displayed on the left axis) and degrees Fahrenheit (displayed on the right axis) are plotted against the variable MONTH. Although the procedure produces two sets of data points, it calibrates the axes so that the data points are identical and it displays only one plot.

This example uses SYMBOL statements to define symbol definitions. By default, the SYMBOL1 statement is assigned to the plot that is generated by the PLOT statement, and SYMBOL2 is assigned to the plot generated by the PLOT2 statement.
 Note about code
libname reflib 'SAS-data-library';
goptions reset=global gunit=pct border cback=white
         colors=(black blue green red)
         ftitle=swissb ftext=swiss htitle=6 htext=3;
 Note about code
data reflib.minntemp;
   input @10 month
         @23 f2;
   c2=(f2-32)/1.8;
   output;
   datalines;
01JAN83  1    1   40.5  12.2  52.1
01FEB83  2    1   42.2  16.5  55.1
   ...more data lines...
01NOV83  11   4   50.0  32.4  59.8
01DEC83  12   1   41.2  18.6  52.5
;
 Note about code
title1 'Average Monthly Temperature for Minneapolis';
footnote1 j=l ' Source: 1984 American Express';
footnote2 j=l '           Appointment Book'
          j=r 'GR21N09 ';
 Note about code
symbol1 interpol=needle
        ci=blue
        cv=red
        width=3
        value=star
        height=3;
 Note about code
symbol2 interpol=none
        value=none;
 Note about code
axis1 label=none
      value=('JAN' 'FEB' 'MAR' 'APR' 'MAY' 'JUN'
             'JUL' 'AUG' 'SEP' 'OCT' 'NOV' 'DEC')
      offset=(2)
      width=3;
axis2 label=('Degrees' justify=right ' Centigrade')
      order=(-20 to 30 by 10)
      width=3;
axis3 label=(h=3 'Degrees' justify=left 'Fahrenheit')
      order=(-4 to 86 by 18)
      width=3;
 Note about code
proc gplot data=reflib.minntemp;
   plot c2*month  / caxis=red
                    haxis=axis1 hminor=0
                    vaxis=axis2 vminor=1
   plot2 f2*month / caxis=red
                    vaxis=axis3
                    vminor=1;
run;
quit;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.