# st: Legend with twoway rarea and a patterned border

 From Davide Cantoni To statalist@hsphsun2.harvard.edu Subject st: Legend with twoway rarea and a patterned border Date Sat, 7 Nov 2009 16:45:32 -0500

```Dear all,

I have a question about an, admittedly minor, aesthetic issue when
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'
replace headr=`X' in `i'
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 "")) ///
scheme(s1mono) xtitle(Headroom) ytitle(Coefficient estimate)

* as a comparison: all black

twoway (rarea ub lb headr, lcolor(gs0) lpattern(longdash)
fcolor(none)) (line beta headr), ///
legend(order(2 1) label(1 "Point est./95% c.i.") label (2 "")) ///
scheme(s1mono) xtitle(Headroom) ytitle(Coefficient estimate)

* as a comparison: all white

twoway (rarea ub lb headr, lcolor(gs0) lpattern(longdash)
fcolor(none)) (line beta headr), ///
legend(order(2 1) label(1 "Point est./95% c.i.") label (2 "")) ///
scheme(s1mono) xtitle(Headroom) ytitle(Coefficient estimate)

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