Sample 25527: Specifying contour levels in contour plots using PROC GCONTOUR
This sample is from the "SAS/GRAPH Software: Reference, Version 8", Volume 2, Chapter 14.
For additional information on the sample refer to this book.
/*+-------------------------------------------------------------+
| S A S S A M P L E L I B R A R Y |
| |
| NAME: GCTPOND |
| TITLE: GCTPOND-Specifying Contour Levels in Contour Plots |
| PRODUCT: GRAPH |
| SYSTEM: ALL |
| KEYS: GRAPHICS GCONTOUR G3GRID AXIS LEGEND |
| PROCS: GCONTOUR |
| DATA: INTERNAL |
| |
| SUPPORT: GRAPHICS STAFF UPDATE: |
| REF: SAS/GRAPH REFERENCE GUIDE |
+-------------------------------------------------------------+*/
/* Set the graphics environment */
goptions reset=all gunit=pct border cback=white
colors=(black blue green red)
ftext=swissb htitle=6 htext=3;
/* Create data set WORK.POND */
data pond;
input vdist hdist height;
datalines;
10 88 0
18 55 -1
24 22.5 -1.67
30 15 -1.42
44 2.5 -1.46
60 20 -1.33
10 82.5 -1
10 72.5 -1.08
10 62.5 -1.38
10 52.5 -1.46
10 42.5 -.5
10 32.5 .42
10 22.5 .67
10 12.5 .67
10 2.5 1
68 20 -.08
76 20 -.63
84 22.5 -.96
20 2.5 1
30 2.5 1
40 2.5 1
50 2.5 1
60 2.5 1
70 2.5 1
80 2.5 1
90 2.5 1
34 12.5 1
34 15 1
34 20 1
54 10 -.06
54 12.5 -.06
54 17.5 -.06
82 10 -1.12
82 12.5 -1.12
82 17.5 -1.12
94 20 -2.17
96 17.5 -2.17
98 15 -2.17
90 27.5 -1.09
96 35 -1.84
100 43.75 -2
104 12.5 -2.34
106 82.5 -2.09
108 102.5 -2
110 142.5 -1.5
110 222.5 -2.34
108 242.5 -2.84
108 262.5 -2.59
106 282.5 -2.01
104 307.5 -1.42
88 302.5 -1.25
72 302.5 .12
56 297.5 .91
40 290 1.33
24 277.5 1.5
0 255 3
88 305 -1.25
88 307.5 -1.25
72 305 .12
72 307.5 .12
56 300 .91
56 305 .91
40 292.5 1.33
40 297.5 1.33
24 282.5 1.5
0 260 3
6 275 -2.09
26 300 -2.67
0 265 3
10 97.5 .04
8 117.5 .33
6 127.5 .25
6 137.5 -.5
4 157.5 -.75
2 177.5 -.92
2 197.5 -.75
0 217.5 -.75
0 237.5 -.92
0 277.5 .42
0 297.5 .75
0 307.5 2
86 37.5 -5
88 37.5 -5
90 38 -5
92 38 -5
94 40 -5
96 42.5 -5
98 47.5 -5
100 55 -5
101 60 -5
102 65 -5
103 70 -5
103.5 72.5 -5
104 75 -5
104 77.5 -5
104 80 -5
104 87.5 -5
104 95 -5
105 105 -5
106 117.5 -5
106 125 -5
107 132.5 -5
107 140 -5
107 147.5 -5
106 155 -5
106 162.5 -5
107 170 -5
107 177.5 -5
109 187.5 -5
110 192.5 -5
110 197.5 -5
110 205 -5
110 210 -5
109 215 -5
108 222.5 -5
106 227.5 -5
106 232.5 -5
105 237.5 -5
104 247.5 -5
104 260 -5
104 270 -5
103 277.5 -5
102 285 -5
101 290 -5
98 293.75 -5
94 295 -5
88 296.25 -5
82 295 -5
76 295 -5
68 293.75 -5
60 291.25 -5
52 287.5 -5
48 285 -5
46 283.75 -5
44 282.5 -5
43 280 -5
40 275 -5
38 270 -5
37 265 -5
35 257.5 -5
34 250 -5
33 242.5 -5
33 232.5 -5
33 225 -5
34 217.5 -5
34 212.5 -5
34 207.5 -5
34 202.5 -5
33 197.5 -5
31 190 -5
29 182.5 -5
26 175 -5
25 170 -5
23 165 -5
22 157.5 -5
21 147.5 -5
21 140 -5
21 135 -5
21 127.5 -5
22 120 -5
23 112.5 -5
26 102.5 -5
28 95 -5
29 92.5 -5
31 90 -5
36 80 -5
40 73.75 -5
44 65 -5
46 60 -5
50 56.25 -5
56 50 -5
64 46.25 -5
72 42.5 -5
78 40 -5
82 38.75 -5
84 31.25 -4
80 32.5 -4
74 35 -4
68 37.5 -4
58 42.5 -4
50 47.5 -4
44 52.5 -4
40 60 -4
36 66.25 -4
32 75 -4
29 80 -4
26 85 -4
24 90 -4
20 90 -4
16 90 -4
1 250 3
6 262.5 2.75
6 270 2.75
14 277.5 2.65
16 272.5 2.65
2 275 3
20 317.5 3.5
30 332.5 4
40 342.5 4.5
50 347.5 5
60 352.5 5
70 355 5
80 355 5
90 355 3
100 352.5 2
106 342.5 1
108 330 0
106 317.5 -1
28 292.5 -2.67
18 300 -2.67
26 315 -2.80
32 310 -2.8
36 300 -2.8
34 327.5 -2.9
42 320 -2.9
48 307.5 -2.9
50 337.5 -3
54 327.5 -3
60 312.5 -3
64 342.5 -3
72 332.5 -3
72 312.5 -3
80 345 -3
86 332.5 -3
88 312.5 -3
98 345 -3
104 330 -3
100 312.5 -3
84 40 -5.08
88 40 -5.08
92 40 -5.08
94 42.5 -5.08
90 42.5 -5.08
86 42.5 -5.5
82 42.5 -5.5
78 42.5 -5.25
70 45 -6.67
80 45 -6.5
86 45 -6
92 45 -5.5
96 45 -5.25
96 47.5 -5.5
92 47.5 -6
86 47.5 -7.5
83 47.5 -7.5
80 47.5 -6.5
76 47.5 -6
70 47.5 -6
66 47.5 -5.5
58 52.5 -6.5
62 52.5 -6.5
66 52.5 -8
72 52.5 -8.5
76 52.5 -8
80 52.5 -7.5
84 52.5 -7
88 52.5 -7
94 52.5 -6.5
98 52.5 -6
48 62.5 -6
52 62.5 -7
58 62.5 -8
64 62.5 -8.5
68 62.5 -9
72 62.5 -9
76 62.5 -8.5
80 62.5 -8.5
84 62.5 -8
90 62.5 -7.5
94 62.5 -7
100 62.5 -6
38 82.5 -6
44 82.5 -6
50 82.5 -6
54 82.5 -7
60 82.5 -7.5
64 82.5 -8.5
68 82.5 -9
74 82.5 -9
80 82.5 -9.5
84 82.5 -10
88 82.5 -8.5
96 82.5 -7
102 82.5 -6
28 102.5 -5.5
34 102.5 -6
40 102.5 -6
44 102.5 -6
48 102.5 -7
54 102.5 -7
60 102.5 -7
64 102.5 -8
68 102.5 -8
74 102.5 -9
80 102.5 -9
86 102.5 -9
92 102.5 -9
94 102.5 -8.5
98 102.5 -7
102 102.5 -6.5
24 122.5 -5.5
30 122.5 -6
36 122.5 -6
42 122.5 -7
48 122.5 -8
54 122.5 -8
60 122.5 -9
66 122.5 -9
69 122.5 -9
72 122.5 -9.5
78 122.5 -9.5
81 122.5 -9
84 122.5 -9
90 122.5 -7.5
93 122.5 -7
96 122.5 -6.5
100 122.5 -6
104 122.5 -5.5
24 142.5 -5.5
32 142.5 -6.5
40 142.5 -8
48 142.5 -8.5
54 142.5 -8.5
60 142.5 -9
68 142.5 -9
74 142.5 -9.5
80 142.5 -9.5
88 142.5 -10
96 142.5 -10
100 142.5 -8
102 142.5 -6
24 162.5 -5.5
28 162.5 -6
32 162.5 -6
36 162.5 -8
40 162.5 -9
44 162.5 -9
50 162.5 -9.5
56 162.5 -9.5
62 162.5 -10
68 162.5 -10
74 162.5 -10
80 162.5 -10
86 162.5 -9.5
92 162.5 -9
98 162.5 -7.5
100 162.5 -7.5
104 162.5 -6
32 182.5 -5.5
68 182.5 -9.5
90 182.5 -10
94 182.5 -8.5
98 182.5 -7
102 182.5 -6.5
106 182.5 -5.5
36 182.5 -5.5
40 182.5 -6
44 182.5 -6
48 182.5 -7
52 182.5 -8.5
56 182.5 -8.5
60 182.5 -9
64 182.5 -9.5
72 182.5 -10
74 182.5 -10
78 182.5 -11
82 182.5 -11
86 182.5 -10.5
36 202.5 -5.5
38 202.5 -6
40 202.5 -7
42 202.5 -7
44 202.5 -9
48 202.5 -9.5
52 202.5 -9.5
56 202.5 -10
60 202.5 -10.5
64 202.5 -10.5
68 202.5 -11
72 202.5 -11
76 202.5 -12
80 202.5 -12
84 202.5 -11.5
88 202.5 -11
92 202.5 -8.5
96 202.5 -7
100 202.5 -7
104 202.5 -6.5
108 202.5 -5.5
36 222.5 -5.5
40 222.5 -6
44 222.5 -7.5
48 222.5 -7.5
52 222.5 -8
56 222.5 -8
60 222.5 -8
64 222.5 -8.5
68 222.5 -8.5
72 222.5 -9.5
76 222.5 -10
80 222.5 -11
84 222.5 -10.5
88 222.5 -10
92 222.5 -9.5
96 222.5 -9
100 222.5 -8
102 222.5 -8
104 222.5 -7
106 222.5 -5.5
36 242.5 -5.5
40 242.5 -5.5
44 242.5 -6.5
48 242.5 -6.5
52 242.5 -7
56 242.5 -7
60 242.5 -7
64 242.5 -7.5
68 242.5 -8
72 242.5 -10
76 242.5 -10
80 242.5 -10
84 242.5 -8.5
88 242.5 -8
92 242.5 -7.5
96 242.5 -6
100 242.5 -6
102 242.5 -5.5
48 282.5 -5.5
52 282.5 -6
60 282.5 -6.5
64 282.5 -8.5
68 282.5 -7.5
72 282.5 -8
80 282.5 -8.5
84 282.5 -8.5
88 282.5 -8
92 282.5 -8.5
96 282.5 -7.5
100 282.5 -6.5
58 287.5 -6.5
64 287.5 -7
72 287.5 -7
80 287.5 -7
88 287.5 -7.5
94 287.5 -7
100 287.5 -6.5
76 290 -7
86 290 -7.5
92 290 -7
98 290 -6.5
68 290 -6.5
80 293.75 -6.5
92 293.75 -6.5
96 293.75 -6.5
62 273.75 -5
60 275 -5
60 272.5 -5
60 270 -5
62 272.5 -5
62 270 -5
40 282.5 -5.5
44 282.5 -6.5
48 282.5 -6.5
52 282.5 -7.5
56 282.5 -8
60 282.5 -8
64 282.5 -8
68 282.5 -9
72 282.5 -9
76 282.5 -8.5
84 282.5 -9
92 282.5 -7.5
96 282.5 -7
100 282.5 -6
44 275 -6.5
48 275 -6.5
52 275 -7
56 275 -6.5
58 275 -6.25
64 275 -6.25
66 275 -6.25
70 275 -7
74 275 -8
78 275 -8.5
82 275 -8.5
86 275 -8.5
90 275 -7
94 275 -7
98 275 -6.5
102 275 -6.5
58 272.5 -6.5
58 270 -6.5
60 267.5 -6.25
62 267.5 -6.25
64 270 -6.25
64 272.5 -6.25
60 277.5 -6.5
62 277.5 -6.5
;
/* Define title and footnote for plot */
title 'Bottom Contour of Mill Pond';
footnote h=3 j=r 'GCTPOND';
/* Define axis characteristics */
axis1 order=(0 to 325 by 25) width=3 minor=(n=4) label=('Feet');
axis2 order=(0 to 100 by 25) width=3 minor=(n=4) label=(' Feet');
/* Define legend characteristics */
legend1 frame
shape=line(7)
label=(position=top j=c 'Height or Depth (in feet)');
/* Process points using G3GRID */
proc g3grid data=pond out=pondgrid;
grid vdist*hdist=height / naxis1=100 naxis2=100;
run;
/* Show the contour plot */
proc gcontour data=pondgrid;
plot vdist*hdist=height /
levels= -30 -12 -7 -5 -3 0 3 5 7 12
llevels= 1 1 1 1 1 2 2 2 2 2
legend=legend1
haxis=axis1
vaxis=axis2;
run;
quit;

In the example, the PLOT statement uses the LEVELS= and LLEVELS= options to specify explicit contour levels and line types for the contour plot. It also uses a LEGEND statement to modify the plot's default legend.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GCONTOUR Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Plots ==> Contour
|
| Date Modified: | 2005-08-27 03:03:19 |
| Date Created: | 2005-05-23 14:13:22 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | 8 TS M0 | n/a |