I am trying to combine 3 coefplots using graph combine in Stata 16. I have coefficient labels on one plot but not on the others. When I combine, the x axis is shorter on the first graph with the coefficient labels so the other two graphs look wider. I'm wondering if there is a way to force the x axes to span the same physical width?
My code is:
Code:
qui svy: mean diff_wt2 diff_ht2 diff_bmi2 if smpl2==1
local mean_1 = e(b)[1,1]
local mean_2 = e(b)[1,2]
local mean_3 = e(b)[1,3]
local yscale "on"
forval x =1/3 {
if `x'==1 local y="Weight"
if `x'==2 local y="Height"
if `x'==3 local y="BMI"
local z1=`x'*3-2
local z2=`x'*3-1
local z3=`x'*3
if `x'==1 local fxsize=100
if inlist(`x',2,3) local fxsize=80
if `x'==1 local ysize=5
if inlist(`x',2,3) local ysize=4
di "`z1' `z2' `z3'"
coefplot (matrix(health_plots[,`z1']), ci((health_plots[,`z2'] health_plots[,`z3']))) , title("`y' SR-M") ///
ylabel(,labsize(small)) ysize(`ysize') xsize(3) xlabel(-10(5)20, labsize(small)) ///
graphregion(color(white) fcolor(white) lcolor(white) ilcolor(white) ifcolor(white)) ///
xscale(range(-10(2)10)) msize(small) /*fxsize(`fxsize')*/ ///
text(1 10 "Long term alcohol", size(small) just(left) place(east)) ///
text(7 10 "Short term alcohol", size(small) just(left) place(east)) ///
text(13 10 "RDI fruit/veg", size(small) just(left) place(east)) ///
text(17 10 "Exercise", size(small) just(left) place(east)) ///
text(20 10 "Physical activity", size(small) just(left) place(east)) ///
text(23 10 "Smoker", size(small) just(left) place(east)) ///
text(28 10 "SEIFA", size(small) just(left) place(east)) ///
text(37 10 "K10", size(small) just(left) place(east)) ///
xline(`mean_`x'') yscale(`yscale') ///
ytitle("Health variable") /*nodraw*/ name("health_`x'", replace)
local yscale "off"
}
graph combine health_1 health_2 health_3, altshrink ///
graphregion(color(white) fcolor(white) lcolor(white) ilcolor(white) ifcolor(white)) title("Health variables") ///
rows(1) xcommon ycommon name("health_vars_all", replace)
0 Response to Uneven length of x axis in graph combine
Post a Comment