Debian Codegraph @

pltestsuite/distrib.htm

raw symbols SCIP
1 <html><h1>distrib</h1><img src="distrib.gif"><p>
2 <a href="gall.using.html">How to download and try this example</a><br>
3
4 <pre><b>Usage: pl -gif distrib.htm
5 or for postscript output: pl -ps distrib.htm | lp
6
7 This is a more elaborate example that involves variables, a loop,
8 automatically calculated distributions for the histograms, etc.
9 <hr></b>
10
11 // <b> set landscape mode and do page title using <a href="../doc/page.html">proc page</a></b>
12 #proc page
13 landscape: yes
14 pagesize: 11 8.5
15 #if @DEVICE in gif,png
16 scale: 0.5
17 #endif
18 title: Distribution of Scores Over Time
19 Protocol 7 vs. Protocol B
20 06-30-99
21
22 // <b> read file <a href="vf.dat">vf.dat</a> using <a href="../doc/getdata.html">proc getdata</a></b>
23 #proc getdata
24 file: vf.dat
25
26
27
28 // <b> set some variables.. </b>
29
30
31 // I will be our loop counter..
32 #set I = 1
33
34 // make a list of the data fields to use for each left member of pair ..
35 // (rt member will be +1)
36 #set FIELDLIST = 7,9,11,13
37
38 // make a list of X left locations for each pair in inches..
39 #set XPOSLIST = 1,3.5,6,8.5
40
41 // make a list of labels for each pair
42 #set LABELLIST = "Baseline,1_yr_visit,2_yr,3_yr"
43
44
45 // <b> loop, once for each pair.. </b>
46 #loop
47
48 // get parameters from lists..
49 #set FLD = $nmember(@I,@FIELDLIST)
50 #if $strlen(@FLD) < 1
51 #break
52 #endif
53 #set XPOS = $nmember(@I,@XPOSLIST)
54 #set LABEL = $nmember(@I,@LABELLIST)
55 #set LABEL = $change( "_", " ", @LABEL )
56
57 //////////////////////////
58 // first do left of pair..
59 //////////////////////////
60
61
62 // <b> set up plotting area for histogram (left member of pair) using <a href="../doc/areadef.html">proc areadef</a></b>
63 #proc areadef
64 box: 1 2.5
65 location: @XPOS 4
66 xrange: 0 40
67 yrange: 0 100
68 #saveas A
69
70 // <b> if the leftmost pair, do a Y axis using <a href="../doc/axis.html">proc yaxis</a></b>
71 #if @I = 1
72 #proc yaxis
73 stubs: inc 10
74 label: Score
75 labeldistance: 0.7
76 stubslide: -2.5(s)
77 ticlen: 0 0
78 #endif
79
80 // <b> if the rightmost pair, do a Y axis using <a href="../doc/axis.html">proc yaxis</a></b>
81 #if @I = 4
82 #proc yaxis
83 location: 10.2
84 label: Score
85 labeldistance: -0.7
86 stubs: inc 10
87 stubdetails: adjust=0.5,0
88 stubslide: -2.5(s)
89 ticlen: 0 0
90 #endif
91
92 // <b> render label above pair using <a href="../doc/annotate.html">proc annotate</a></b>
93 #proc annotate
94 location: max-0.2 max+0.2
95 textdetails: align=C
96 text: @LABEL
97
98 // <b> compute distribution for histogram using <a href="../doc/tabulate.html">proc tabulate</a></b>
99 #proc tabulate
100 axis1: y
101 datafield1: @FLD
102 rangespec1: 0 5 95
103 percents: yes
104 select: @@4 = B
105 showrangelowonly: yes
106 #saveas: T
107
108 // <b> we cannot do a histogram if N is too low.. find N using <a href="../doc/transform.html">proc processdata</a></b>
109 // (the variable TOTALS will be set)..
110 #proc processdata
111 action: total
112 fields: 2
113 #endproc
114
115
116 // only do the histogram if we have > 10 cases..
117 #if @TOTALS > 10
118
119 // <b> render histogram using <a href="../doc/bars.html">proc bars</a></b>
120 #proc bars
121 horizontalbars: yes
122 locfield: 1
123 lenfield: 3
124 barwidth: 0.08
125 #saveas B
126
127 #endif
128
129 // <b> now set up plotting area for rangebars using <a href="../doc/areadef.html">proc areadef</a></b>
130 #proc areadef
131 box: 1 2
132 location: @XPOS 1
133 xrange: 0 1
134 yrange: 0 100
135 #saveas A2
136
137 // <b> if leftmost pair do a Y axis using <a href="../doc/axis.html">proc yaxis</a></b>
138 #if @I = 1
139 #proc yaxis
140 stubs: inc 10
141 label: Score
142 labeldistance: 0.7
143 #endif
144 // <b> if rightmost pair do a Y axis using <a href="../doc/axis.html">proc yaxis</a></b>
145 #if @I = 4
146 #proc yaxis
147 location: 10.2
148 label: Score
149 labeldistance: -0.7
150 stubs: inc 10
151 stubdetails: adjust=0.5,0
152 ticlen: -0.1
153 #endif
154
155 // <b> get back to original set of data (<a href="../doc/originaldata.html">proc originaldata</a>)</b>
156 #proc originaldata
157
158 // <b> render rangebar using <a href="../doc/rangebar.html">proc rangebar</a></b>
159 #proc rangebar
160 select: @@4 = B
161 datafield: @FLD
162 barloc: 0.25
163 mediansym: shape=circle style=filled fillcolor=0.3
164 nlocation: -10(s)
165 color: 0.9
166 #saveas R
167
168 ////////////////////////////
169 // now do right of pair..
170 // (repeat of procedure above)
171 ////////////////////////////
172
173 #set XPOS = $arith(@XPOS+1.0)
174
175 // do histogram..
176 #proc areadef
177 #clone A
178 location: @XPOS 4
179
180 #proc tabulate
181 #clone: T
182 select: @@4 = 7
183
184 // see if total is high enough to display histogram..
185 #proc processdata
186 action: total
187 fields: 2
188 #endproc
189
190
191 // only do the histogram if we have > 10 cases..
192 #if @TOTALS > 10
193
194 #proc bars
195 #clone B
196
197 #endif
198
199 // do rangebar..
200 #proc areadef
201 #clone: A2
202 location: @XPOS 1
203
204 // get back to data set originally read..
205 #proc originaldata
206
207 #proc rangebar
208 #clone R
209 select: @@4 = 7
210 barloc: 0.15
211 datafield: @FLD
212
213 #set I = $arith(@I+1)
214
215 #endloop