# Re: st: RE: Legend with twoway rarea and a patterned border

 From Davide Cantoni To statalist@hsphsun2.harvard.edu Subject Re: st: RE: Legend with twoway rarea and a patterned border Date Sun, 8 Nov 2009 09:07:04 -0500

```Dear Martin,

> Normally playing around with the Graph Editor solves this stuff, but I could not find the magic bullet in this case... Still, why not just go for three -line-s then?

overlooked. The reason why I do not use three lines is that actually
in my real graph I have two -rarea-s partly overlapping, and I want
the legend to reflect this accordingly:

*** begin example

sysuse auto, clear

gen beta=.
gen se=.
gen lb=.
gen ub=.

local i=0

foreach X of local levelsofheadr {
local i `=`i'+1'
qui reg mpg weight if headroom==`X'
replace beta=_b[weight] in `i'
replace se=_se[weight] in `i'
}

replace lb = beta-invnormal(0.975)*se
replace ub = beta+invnormal(0.975)*se

gen beta2=.
gen se2=.
gen lb2=.
gen ub2=.

foreach X of local levelsofheadr {
qui reg mpg price if headroom==`X'
}

replace lb2 = beta2-invnormal(0.975)*se2
replace ub2 = beta2+invnormal(0.975)*se2

(rarea ub2 lb2 headr, lpattern(longdash) fcolor(none)) ///
legend(order(2 1 4 3) label(1 "Point est./95% c.i.: mpg on weight") ///
label (2 "") label(3 "Point est./95% c.i.: mpg on price") label (4 "")) ///

*** end example

And such a legend, I think, would be hard to achieve with -twoway
line-. Not to speak of the vertical lines that join the upper and
lower bound of the ci...

Thanks for your thoughts on this,

Davide
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```