~ubuntu-branches/ubuntu/wily/ploticus/wily

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<html><h1>distrib</h1><img src="distrib.gif"><p>
<a href="gall.using.html">How to download and try this example</a><br>

<pre><b>Usage: pl -gif distrib.htm
or for postscript output: pl -ps distrib.htm | lp 

This is a more elaborate example that involves variables, a loop,
automatically calculated distributions for the histograms, etc.
<hr></b>

// <b> set landscape mode and do page title using <a href="../doc/page.html">proc page</a></b>
#proc page
landscape: yes
pagesize: 11 8.5
#if @DEVICE in gif,png
  scale: 0.5
#endif
title:  Distribution of Scores Over Time
	Protocol 7 vs. Protocol B
	06-30-99

// <b> read file <a href="vf.dat">vf.dat</a> using <a href="../doc/getdata.html">proc getdata</a></b>
#proc getdata
file: vf.dat



// <b> set some variables.. </b>


// I will be our loop counter..
#set I = 1

// make a list of the data fields to use for each left member of pair ..
// (rt member will be +1)
#set FIELDLIST = 7,9,11,13   

// make a list of X left locations for each pair in inches..
#set XPOSLIST = 1,3.5,6,8.5

// make a list of labels for each pair
#set LABELLIST = "Baseline,1_yr_visit,2_yr,3_yr"


// <b> loop, once for each pair.. </b>
#loop

  // get parameters from lists..
  #set FLD = $nmember(@I,@FIELDLIST)
  #if $strlen(@FLD) < 1
    #break
  #endif
  #set XPOS = $nmember(@I,@XPOSLIST)
  #set LABEL = $nmember(@I,@LABELLIST)
  #set LABEL = $change( "_", " ", @LABEL )
  
  //////////////////////////
  // first do left of pair..
  //////////////////////////


  // <b> set up plotting area for histogram (left member of pair) using <a href="../doc/areadef.html">proc areadef</a></b>
  #proc areadef
  box: 1 2.5
  location: @XPOS 4
  xrange: 0 40
  yrange: 0 100
  #saveas A
  
  // <b> if the leftmost pair, do a Y axis using <a href="../doc/axis.html">proc yaxis</a></b>
  #if @I = 1
    #proc yaxis
    stubs: inc 10
    label: Score
    labeldistance: 0.7
    stubslide: -2.5(s)
    ticlen: 0 0
  #endif

  // <b> if the rightmost pair, do a Y axis using <a href="../doc/axis.html">proc yaxis</a></b>
  #if @I = 4
    #proc yaxis
    location: 10.2
    label: Score
    labeldistance: -0.7
    stubs: inc 10
    stubdetails: adjust=0.5,0
    stubslide: -2.5(s)
    ticlen: 0 0
  #endif

  // <b> render label above pair using <a href="../doc/annotate.html">proc annotate</a></b>
  #proc annotate
  location: max-0.2 max+0.2
  textdetails: align=C
  text: @LABEL
  
  // <b> compute distribution for histogram using <a href="../doc/tabulate.html">proc tabulate</a></b>
  #proc tabulate
  axis1: y
  datafield1: @FLD
  rangespec1: 0 5 95
  percents: yes
  select: @@4 = B
  showrangelowonly: yes
  #saveas: T
  
  // <b> we cannot do a histogram if N is too low.. find N using <a href="../doc/transform.html">proc processdata</a></b>
  // (the variable TOTALS will be set)..
  #proc processdata
  action: total
  fields: 2
  #endproc


  // only do the histogram if we have > 10 cases..
  #if @TOTALS > 10

    // <b> render histogram using <a href="../doc/bars.html">proc bars</a></b>
    #proc bars
    horizontalbars: yes
    locfield:  1
    lenfield:  3
    barwidth: 0.08
    #saveas B

  #endif

  // <b> now set up plotting area for rangebars using <a href="../doc/areadef.html">proc areadef</a></b>
  #proc areadef
  box: 1 2
  location: @XPOS 1
  xrange: 0 1
  yrange: 0 100
  #saveas A2

  // <b> if leftmost pair do a Y axis using <a href="../doc/axis.html">proc yaxis</a></b>
  #if @I = 1
    #proc yaxis
    stubs: inc 10
    label: Score
    labeldistance: 0.7
  #endif
  // <b> if rightmost pair do a Y axis using <a href="../doc/axis.html">proc yaxis</a></b>
  #if @I = 4
    #proc yaxis
    location: 10.2
    label: Score
    labeldistance: -0.7
    stubs: inc 10
    stubdetails: adjust=0.5,0
    ticlen: -0.1
  #endif

  // <b> get back to original set of data (<a href="../doc/originaldata.html">proc originaldata</a>)</b>
  #proc originaldata
  
  // <b> render rangebar using <a href="../doc/rangebar.html">proc rangebar</a></b>
  #proc rangebar
  select: @@4 = B
  datafield: @FLD
  barloc: 0.25
  mediansym: shape=circle style=filled fillcolor=0.3
  nlocation: -10(s)
  color: 0.9
  #saveas R

  ////////////////////////////
  // now do right of pair.. 
  // (repeat of procedure above)
  ////////////////////////////

  #set XPOS = $arith(@XPOS+1.0)

  // do histogram..
  #proc areadef
  #clone A
  location: @XPOS 4

  #proc tabulate
  #clone: T
  select: @@4 = 7

  // see if total is high enough to display histogram.. 
  #proc processdata
  action: total
  fields: 2
  #endproc


  // only do the histogram if we have > 10 cases..
  #if @TOTALS > 10

    #proc bars
    #clone B

  #endif

  // do rangebar..
  #proc areadef
  #clone: A2
  location: @XPOS 1

  // get back to data set originally read..
  #proc originaldata
  
  #proc rangebar
  #clone R
  select: @@4 = 7
  barloc: 0.15
  datafield: @FLD

  #set I = $arith(@I+1)

#endloop