Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: several gr hbar but wants bar of same size


From   "Scott Merryman" <scott.merryman@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: several gr hbar but wants bar of same size
Date   Tue, 21 Aug 2007 09:00:39 -0500

Ok, thanks for the example.  I think I understand now.

Does the following code accomplish what you want (It assumes you
already know that the maximum number of categories is 26):

clear
input str2 tests   noof    pos   str4  timetest
bb      3       4.96    sysa
hh      4       4.98    sysa
ss      6       4.56    sysa
uu      7       21.33   sysa
zz      5       145.19  sysa
a4      5       37.69   sysa
a5      4       9.98    sysa
a6      7       6.85    sysa
a7      5       15.71   sysa
a8      4       7.02    sysa
a9      5       4.81    sysa
b1      7       4.61    sysa
d1      9       12.51   sysa
e1      3       4.75    sysa
f1      12      6.96    sysa
g1      4       6.95    sysa
m3      11      7.32    sysa
n1      7       5.69    sysa
r1      7       3.93    sysa
aa      5       6.70    sysb
dd      4       4.25    sysb
ii      5       3.95    sysb
jj      5       4.26    sysb
kk      14      3.14    sysb
oo      5       5.68    sysb
pp      5       2.90    sysb
ss      6       3.71    sysb
uu      7       5.48    sysb
b6      7       3.52    sysb
d1      17      28.71   sysb
e1      5       7.23    sysb
f1      12      4.59    sysb
g1      4       5.63    sysb
h1      28      4.96    sysb
i1      15      4.60    sysb
j1      3       6.50    sysb
l1      4       7.79    sysb
l2      4       4.88    sysb
m1      11      3.96    sysb
m2      11      4.96    sysb
n2      7       3.76    sysb
o1      3       4.39    sysb
o4      4       5.10    sysb
o5      12      3.25    sysb
q1      7       3.54    sysb
cc      12      9.77    sysx
nn      9       7.26    sysx
uu      7       6.98    sysx
yy      3       7.03    sysx
b2      6       4.21    sysx
d1      10      6.31    sysx
j1      5       6.49    sysx
o3      3       9.08    sysx
o6      7       3.77    sysx
q2      7       3.81    sysx
ee      12      30.95   sysz
kk      10      3.33    sysz
ll      5       4.53    sysz
qq      9       4.17    sysz
rr      6       3.73    sysz
uu      7       4.83    sysz
yy      3       4.86    sysz
a3      3       5.69    sysz
b3      5       4.62    sysz
d1      33      10.30   sysz
j1      11      6.20    sysz
k1      3       4.62    sysz
k1      3       4.69    sysz
l1      4       4.64    sysz
n3      3       6.39    sysz
o2      6       4.65    sysz
o8      7       3.46    sysz
p1      4       9.66    sysz
q2      7       3.13    sysz
s1      12      4.71    sysz
ff      12      6.09    sysk
gg      6       38.33   sysk
nn      9       4.24    sysk
a1      4       8.76    sysk
c1      5       18.41   sysk
j1      5       4.06    sysk
o7      7       4.38    sysk
ff      12      9.35    sysL
gg      6       30.83   sysL
mm      5       8.40    sysL
nn      9       6.34    sysL
tt      6       4.67    sysL
uu      7       3.81    sysL
a2      8       10.94   sysL
c1      8       6.33    sysL
d1      20      5.85    sysL
j1      5       5.16    sysL
n3      3       5.45    sysL
o2      6       36.70   sysL
o9      7       5.67    sysL
end

levelsof time,local(levels)
foreach l of local levels {
count if time == "`l'"
if r(N) !=26 {
local size = ((26-2)/r(N))*2.5
}
else {
	local size = 1
}
disp "`size'"

gr hbar noof if timetest=="`l'", over(test, sort(pos) gap(*`size')
label(labsize(*.65))) ///
 ytitle("No. of studies")  ysc(r(0 35)) ylab(0 (5) 35) ///
 name(gr_`l',replace)
local name "`name' gr_`l'"
}
graph combine `name'



On 8/21/07, b. water <barleywater@hotmail.com> wrote:
<snip>
> i want to produce gr hbar ala [G] page 119 for each varlists in timetest,
> which i can accomplish easy enough, ending up with 6 hbar graphs. naturally,
> the size of the hbar would be different for each graph. what i want to
> achieve is these six graphs but with consistent hbar size accross the six
> graphs. so overall, i would end up with graphs that have the x-axis
> (horizontal perimeter) of the graph consistent because i am fixing it with
> ysc(r(0 35)) ylab(0 (5) 35) but that the y-axis (vertical perimeter) of
> differing lengths depending on obviously on the no. of tests.
>
> scott's suggested approach, while feasible, is not ideal because some of the
> tests are not applicable to some of the varlists, resulting, if scott's
> suggested approach was used, redundant gaps in the various graphs.
> furthermore, there will be more tests and different testtime varlists to be
> added in the future.
>
> not only i wanted to do the hbar in the way i have described with consistent
> hbar size, i was hoping that the answer from statalisters would enable me to
> apply it to creation of consistent gr hbox size, ala [G] page 152, but again
> with differing y-axis (vertical perimeter) lengths depending on the no. of
> tests.
>
> down the road, i am want to combine the six graphs (for now) with gr combine
> so that i have two  panels ala [G] page 142 and page 158 respectively but
> obviously then each column in the respective panels would be of different
> vertical size.
>
> after going through [G] i am not certain that i wanted is achievable, at
> least not on stata 8.2 hence the question to statalisters. there might be a
> 'lateral thinking' solution to achieve what i envisage but at the moment i
> am drawing blanks.
>
> hope i have made it clearer. all [G] references are of course stata 8.2.
> again, thank you in advance.
>
> regards,
> bw
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index