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

 From "Martin Weiss" To Subject st: RE: Legend with twoway rarea and a patterned border Date Sun, 8 Nov 2009 00:38:46 +0100

```<>

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?

*******
sysuse auto, clear

statsby beta=_b[weight] se=_se[weight], /*
*/ reg mpg weight

gen lb = beta-invnormal(0.975)*se
gen ub = beta+invnormal(0.975)*se
lab var beta "Point Estimate"

*/ lpattern(longdash) fcolor(none)) /*
*/ lpattern(longdash) fcolor(none)) /*
*/ (line beta headr), scheme(s1mono)  /*
*/ ytitle(Coefficient estimate)
*******

HTH
Martin

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Davide Cantoni
Sent: Samstag, 7. November 2009 22:46
To: statalist@hsphsun2.harvard.edu
Subject: st: Legend with twoway rarea and a patterned border

Dear all,

using -twoway rarea- with a patterned border. The curious issue there
is that, while the pattern of the area's border is, say, "grey
line/white space/grey line" and so on, the corresponding legend
element ("thumbnail", so to speak) has "grey line/black space/grey
line". This is particularly nasty when you use a black patterned
border (e.g. "lcolor(gs0) lpattern(dash)"), because then in the legend
it is not clear that the corresponding rarea element has a patterned
border, as it then is: "black line/black space/black line".

Here's a minimal working example:

*** 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

twoway (rarea ub lb headr, lpattern(longdash) fcolor(none)) (line beta
legend(order(2 1) label(1 "Point est./95% c.i.") label (2 "")) ///

* as a comparison: all black

twoway (rarea ub lb headr, lcolor(gs0) lpattern(longdash)
legend(order(2 1) label(1 "Point est./95% c.i.") label (2 "")) ///

* as a comparison: all white

twoway (rarea ub lb headr, lcolor(gs0) lpattern(longdash)
legend(order(2 1) label(1 "Point est./95% c.i.") label (2 "")) ///

*** end example

Also, let me hasten to add that it does not depend on the choice of
-fcolor(none)- or of -scheme(s1mono)-. These choices just make the
phenomenon clearer.

Do you have any idea why this comes about, and how to avoid it?

Best, 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/

*
*   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/
```