Dear Statalist:
I cannot get two lines to show on my twoway graph: The top line of the x-axis where I added two area graphs and a vertical line (at 1990.6) where the two area graphs meet.
(Thanks to Nick Cox I figured out everything else - thank you so much, Nick!)
I am using Stata 15.1 .
Here is my code:
# delimit ;
sort yob east;
statsby mean=r(mean) ub=r(ub) lb=r(lb) N=r(N), by(yob east) clear: ci means smoking;
label variable mean "Smoking Rates";
gen upper = 0.8;
sort yob;
local area upper y if inrange(y, 1989.8, 1990.6), bcolor(bluishgray) base(0);
local area2 upper y if inrange(y, 1990, 1993), bcolor(ltbluishgray) base(0);
local scatter1 mean yob if east==0, connect(direct) lcolor(black) mcolor(black) msymbol(triangle);
local scatter2 mean yob if east==1, connect(direct) lcolor(blue) mcolor(blue) xlabel(#15) xla(, ang(45)) plotregion(margin(zero));
twoway area `area' xline(1989.8 1993, lcolor(black) lpattern(dash)) ytitle("Smoking Rates")
|| area `area2' xline(1990.6, lcolor(black) lpattern(dash))
|| rcap ub lb yob if east==0, lcolor(black) || scatter `scatter1'
||rcap ub lb yob if east==1, lcolor(blue)
|| scatter `scatter2' text(.12 1990.1 "Crossing" .12 1991.8 "In Transition", orient(vertical) alignment(top) color(navy)) text(.33 1999 "East" 0.167 1999 "West") legend(off) xscale(range(1994 2000)) xlabel(1984/1998);

I tried adding a horizontal line on top with: yline(1984 2000, lcolor(black) lstyle(foreground)) , but that did not do anything.
(I tried to upload the graph but it does not show on the preview, I hope it shows.)
I cannot get two lines to show on my twoway graph: The top line of the x-axis where I added two area graphs and a vertical line (at 1990.6) where the two area graphs meet.
(Thanks to Nick Cox I figured out everything else - thank you so much, Nick!)
I am using Stata 15.1 .
Here is my code:
# delimit ;
sort yob east;
statsby mean=r(mean) ub=r(ub) lb=r(lb) N=r(N), by(yob east) clear: ci means smoking;
label variable mean "Smoking Rates";
gen upper = 0.8;
sort yob;
local area upper y if inrange(y, 1989.8, 1990.6), bcolor(bluishgray) base(0);
local area2 upper y if inrange(y, 1990, 1993), bcolor(ltbluishgray) base(0);
local scatter1 mean yob if east==0, connect(direct) lcolor(black) mcolor(black) msymbol(triangle);
local scatter2 mean yob if east==1, connect(direct) lcolor(blue) mcolor(blue) xlabel(#15) xla(, ang(45)) plotregion(margin(zero));
twoway area `area' xline(1989.8 1993, lcolor(black) lpattern(dash)) ytitle("Smoking Rates")
|| area `area2' xline(1990.6, lcolor(black) lpattern(dash))
|| rcap ub lb yob if east==0, lcolor(black) || scatter `scatter1'
||rcap ub lb yob if east==1, lcolor(blue)
|| scatter `scatter2' text(.12 1990.1 "Crossing" .12 1991.8 "In Transition", orient(vertical) alignment(top) color(navy)) text(.33 1999 "East" 0.167 1999 "West") legend(off) xscale(range(1994 2000)) xlabel(1984/1998);
I tried adding a horizontal line on top with: yline(1984 2000, lcolor(black) lstyle(foreground)) , but that did not do anything.
(I tried to upload the graph but it does not show on the preview, I hope it shows.)
Comment