Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
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
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: 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,

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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index