Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: String variable as text labels below x-axis


From   Nick Winter <[email protected]>
To   [email protected]
Subject   Re: st: String variable as text labels below x-axis
Date   Thu, 08 Jul 2004 11:23:38 -0400

You can build up your graph command within a loop as well -- something like:


local gcmd sc a b c Y,xlabel( ,val ) c(l l l )
forvalues i=1/`r(tokens)' {
local gcmd `gcmd' || sc pos`i' Y , ms(i) mlabpos(0) mlabel(names_`i')
}

Then just issue the graph command:

`gcmd'

Hope this helps. By the way, instead of a -while- loop, -forvalues- is easier to code and more transparent. But both work.

--Nick Winter


At 07:19 AM 7/8/2004 -0700, you wrote:

Thanks Nick,

No it's one course per plot but lots of such plots to
be produced. Anyway, while I was waiting for responses
I tried to find a solution and I ended up with
something that looks similar to your solution (I used
the vtokenize to ... tokenize names)

sum a
local ma=r(max)
sum b
local mb=r(max)
sum c
local mc=r(max)
vtokenize names

local i=1
while(`i'<=real(r(tokens))){
        gen pos`i'=max(`ma',`mb',`mc')+`i'/4
        local i=`i'+1
        }

sc a b c  Y,xlabel( ,val  ) c(l l l )  || sc pos1
Y,ms(i) mlabpos(0) mlabel(names_1)  xscale(range(0.5
6.5)) /*
*/ || sc pos2 Y,ms(i) mlabpos(0) mlabel(names_2) /*
*/ || sc pos3 Y,ms(i) mlabpos(0) mlabel(names_3) /*
*/ || sc pos4 Y,ms(i) mlabpos(0) mlabel(names_4) /*
*/legend(order(1 2 3) row(1))

The only problem now is that I don't know the number
of instructors a priori thus the number of additional
scatter commands (sc pos* Y) must be manually modified
for each course-dataset-plot. I used the returned
result r(tokens) to generate the positions but I can't
figure out how to deal with the multiple scatter
commands.

Thanks again for your help

Nikos Pantazis
Biostatistician



__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
*
*   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/
--------------------------------------------------------
Nicholas Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government [email protected] e
308 White Hall falcon.arts.cornell.edu/nw53 w
Cornell University
Ithaca, NY 14853-4601

*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index