Chapter Contents

Previous

Next
SAS/GRAPH Software: Reference

Example 2. Specifying Logarithmic Axes

Features:
AXIS statement options:
LABEL=
LENGTH=
LOGBASE=
LOGSTYLE=
MAJOR=
MINOR=
VALUE=
TITLE statement option:
MOVE=
GOPTIONS statement options:
GUNIT=
VPOS=

Sample library member: GR08N02

[IMAGE]

This example illustrates the AXIS statement options LOGBASE= and LOGSTYLE=. The horizontal axis represents pH level. The vertical axis, which represents the concentration of the hydroxide ion expressed as moles per liter, is scaled logarithmically. In addition, this example shows how the TICK= parameter of the VALUE= option modifies individual tick marks.

The example uses the MOVE= option in a TITLE statement to position the title's subscript and superscript text.

Assign the libref and set the graphics environment. GUNIT= specifies units of percent of the graphics output area. VPOS= specifies a resolution for the vertical axis.

libname reflib 'SAS-data-library';
goptions reset=global gunit=pct border cback=white
         colors=(black blue green red) vpos=250
         ftitle=swissb ftext=swiss htitle=5
         htext=3;

Create the data set. REFLIB.CONCENTR contains the pH values and the concentration amount.

data reflib.concentr;
     input ph conc;
     datalines;
1  1E-1
2  1E-2
...more data lines...
13 1E-13
14 1E-14
;

Define title and footnote. MOVE= positions subscript 3 and superscript +. Each new position is relative to the last position specified by MOVE=.

title1 'Relationship of pH to H'
       move=(-0,-3) h=4 '3'
       move=(+0,+3) h=5 'O'
       move=(+0,+3) h=4 '+'
       move=(-0,-3) h=5 ' Concentration';
footnote j=r 'GR09N02  ';

Define symbol characteristics.

symbol interpol=join color=blue;

Define characteristics for horizontal axis. LABEL= uses the JUSTIFY= suboption to create a descriptive two-line label that replaces the variable name PH. MINOR=NONE removes all minor tick marks. LENGTH= uses the units specified by the GUNIT= graphics option to control the length of the horizontal axis.

axis1 label=(h=4 'Scale of pH Values'
             justify=left color=red
             h=3 'More acid'
             justify=right color=blue
             'More alkaline')
      minor=none
      length=60
      width=3;

Define characteristics for vertical axis. LOGBASE=10 scales the vertical axis logarithmically, using a base of 10. Each major tick mark represents a power of 10. LOGSTYLE=EXPAND displays minor tick marks in logarithmic progression. LABEL= uses the ANGLE= suboption to place the label parallel to the vertical axis. VALUE= displays the major tick mark values as 10 plus an exponent. The HEIGHT= suboption for each TICK= specification affects only the text following it. Units of CM override the default PCT specified by GUNIT=.

axis2 logbase=10
      logstyle=expand
      color=red
      label=(angle=90 h=4 color=black
             'Concentration (Moles/Liter)' )
      value=(tick=1 '10' height=1.5 '-14'
             tick=2 '10' height=1.5 '-13'
             tick=3 '10' height=1.5 '-12'
             tick=4 '10' height=1.5 '-11'
             tick=5 '10' height=1.5 '-10'
             tick=6 '10' height=1.5 '-9'
             tick=7 '10' height=1.5 '-8'
             tick=8 '10' height=1.5 '-7'
             tick=9 '10' height=1.5 '-6'
             tick=10 '10' height=1.5 '-5'
             tick=11 '10' height=1.5 '-4'
             tick=12 '10' height=1.5 '-3'
             tick=13 '10' height=1.5 '-2'
             tick=14 '10' height=1.5 '-1')
      major=(height=.75 cm)
      minor=(color=blue height=.5 cm);

Generate the plot and assign AXIS definitions. AXIS1 modifies the horizontal axis and AXIS2 modifies the vertical axis.

proc gplot data=reflib.concentr;
   plot conc*ph / haxis=axis1
                  vaxis=axis2;
run;
quit;


Chapter Contents

Previous

Next

Top of Page

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