<>
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
drop if headroom>=5
statsby beta=_b[weight] se=_se[weight], /*
*/ by(headroom) clear: /*
*/ reg mpg weight
gen lb = beta-invnormal(0.975)*se
gen ub = beta+invnormal(0.975)*se
lab var beta "Point Estimate"
tw (line ub headr, /*
*/ lpattern(longdash) fcolor(none)) /*
*/ (line lb headr, /*
*/ lpattern(longdash) fcolor(none)) /*
*/ (line beta headr), scheme(s1mono) /*
*/ xtitle(Headroom) legend(row(1)) /*
*/ ytitle(Coefficient estimate)
*******
HTH
Martin
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Davide Cantoni
Sent: Samstag, 7. November 2009 22:46
To: [email protected]
Subject: st: Legend with twoway rarea and a patterned border
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
drop if headroom>=5
gen headr=.
gen beta=.
gen se=.
gen lb=.
gen ub=.
levelsof headroom, local(levelsofheadr)
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
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 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/
*
* 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/