Not a great solution, but how about placing the text if the value labels.
clear
sysuse auto
label drop origin
count if mpg<. & weight<. & foreign==1
local for = string(r(N), "%2.0f")
count if mpg<. & weight<. & foreign==0
local dom = string(r(N), "%2.0f")
label define origin 0 "Domestic, N = `dom'" 1 "Foreign, N = `for'"
label values fore origin
scatter mpg weight, by(foreign)
Scott
----- Original Message -----
From: "Friedrich Huebler" <[email protected]>
To: <[email protected]>
Sent: Wednesday, January 14, 2004 10:13 AM
Subject: st: Text in by() graphs
> Is it possible to add different text to the individual plots in a
> by() graph? In a response to a question by Joseph Wagner I posted
> these commands two days ago:
>
> . sysuse auto
> . count if mpg<. & weight<. & foreign==1
> . local for = string(r(N), "%2.0f")
> . count if mpg<. & weight<. & foreign==0
> . local dom = string(r(N), "%2.0f")
> . scatter mpg weight, by(foreign) text(40 1000 "N = `for'") text(40
> 4000 "N = `dom'")
>
> "N = 52" indicates the number of domestic cars and "N = 22" the
> number of foreign cars. The text should appear in the appropriate
> plots but with the -scatter- command above each of the sample sizes
> is shown twice in the graph. I could not find a solution in the Stata
> graphics manual. Options -xaxis()- and -yaxis()-, which looked
> promising, apparently do not apply to -by()- graphs.
>
> . scatter mpg weight, by(foreign) text(40 1000 "N = `for'", xaxis(2))
> text(40 4000 "N = `dom'", xaxis(1))
> text() option invalid, specified axis pair (1 2) not in graph
> invalid syntax
> invalid syntax
> invalid syntax
> r(198);
>
> Thank you for your help.
>
> Friedrich Huebler
*
* 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/