Chapter Contents

Previous

Next
The G3D Procedure

Example 5: Using Shapes in Scatter Plots


Procedure features:
SCATTER statement options:
COLOR=
GRID
NONEEDLE
SHAPE=
Other features:
DATA step
LABEL statement
NOTE statement
Data set: REFLIB.IRIS
Sample library member: GR29N05

[IMAGE]

This program modifies that shown in Generating a Simple Scatter Plot to use shape symbols and color to distinguish information for various iris species. It also uses NOTE statements to simulate a plot legend.

The program then generates a second plot to modify the first. As shown by the following output, the second plot request suppresses the needles that connect data points to the horizontal plane, and adds reference lines to make it easier to interpret data values. It also labels the plot axes with descriptive text.

[IMAGE]

 Note about code
libname reflib 'SAS-data-library';
goptions reset=global gunit=pct border cback=white
         colors=(black blue green red)
         ftext=swiss ftitle=swissb htitle=6 htext=4;
 Note about code
data reflib.iris2;
   set reflib.iris;
   length species $12. colorval $8. shapeval $8.;
   if spec_no=1 then
      do;
         species='setosa';
         shapeval='club';
         colorval='blue';
      end;
   if spec_no=2 then
      do;
         species='versicolor';
         shapeval='diamond';
         colorval='red';
      end;
   if spec_no=3 then
      do;
         species='virginica';
         shapeval='spade';
         colorval='green';
      end;
run;
 Note about code
title1 'Iris Species Classification';
title2 'Physical Measurement';
title3 'Source: Fisher (1936) Iris Data';
footnote1 j=l '  Petallen: Petal Length in mm.'
          j=r 'Petalwid: Petal Width in mm. ';
footnote2 j=l '  Sepallen: Sepal Length in mm.'
          j=r 'Sepal Width not shown      ';
footnote3 j=r 'GR29N05(a) ';
 Note about code
proc g3d data=reflib.iris2;
   scatter petallen*petalwid=sepallen
         / color=colorval
           shape=shapeval;
 Note about code
   note;
   note j=r 'Species:   ' c=green 'Virginica       '
        j=r c=red 'Versicolor      '
        j=r c=blue 'Setosa         ';
run;
 Note about code
title3;
footnote1 j=l '  Source: Fisher (1936) Iris Data';
footnote2 j=r 'GR29N05(b) ';
 Note about code
proc g3d data=reflib.iris2;
   scatter petallen*petalwid=sepallen
         / noneedle
           grid
           color=colorval
           shape=shapeval;
 Note about code
   label petallen='Petal Length'
         petalwid='Petal Width'
         sepallen='Sepal Length';
run;
quit;


Chapter Contents

Previous

Next

Top of Page

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