当它们重叠时如何在我的图表中移动线条

How to move lines in my graph when they overlap

我想用下面的代码在 Stata 中绘制系数图。

但是,有一个问题。

twoway  (scatter dv2 coef  if  controls=="basic", mcolor(blue) msize() lp(solid) msymbol(o) lwi(vthin) lcolor(blue)) ///
        (rcap ci_upper ci_lower dv2 if  controls=="basic", hor msymbol(dot) lwi() mcolor(blue) lcolor(blue) lp(dash))  ///
        (scatter dv2 coef  if controls=="w/o sampling weight", mcolor(red) msize()  lp(dash) msymbol(s) lwi(vthin)  lcolor(red)) ///
        (rcap ci_upper ci_lower dv2  if controls=="w/o sampling weight", hor  msymbol(dot) lwi()  mcolor(red) lcolor(red) lp(dash)),  ///
        title(Industry)  ytick(, grid) /*ylabel(1 "`: label (age_cat) 1'" 2 "`: label (age_cat) 2'" 3 "`: label (age_cat) 3'" 4 "`: label (age_cat) 4'", /// 
        labsize(small))*/ legend(pos(6) col(3)  order(1 "with sampling weight" 3 "without sampling weight")) ///
        ylabel() xtitle("Coefficient on Covid19 Pandemic", size(small)) xline(0, lc(black) lp(dash)) xlabel(-0.2(0.05)0.2) plotregion(margin(.1))  graphregion(color(white)) bgcolor(white)  xtit() ytit("", size(small)) 

我的代码生成了这张图片。

但是,我看到的图表有重叠。我想移动我画的图,但是不知道需要什么代码

您需要偏移每个子集。这里 0.1 只是象征:使用适合您的任何值。有关更多讨论,请参阅 this paper

gen dvb = dv2 + 0.1 
gen dvc = dv2 - 0.1 

twoway  (scatter dvb coef  if  controls=="basic", mcolor(blue) msize() lp(solid) msymbol(o) lwi(vthin) lcolor(blue)) ///
        (rcap ci_upper ci_lower dvb if  controls=="basic", hor msymbol(dot) lwi() mcolor(blue) lcolor(blue) lp(dash))  ///
        (scatter dvc coef  if controls=="w/o sampling weight", mcolor(red) msize()  lp(dash) msymbol(s) lwi(vthin)  lcolor(red)) ///
        (rcap ci_upper ci_lower dvc if controls=="w/o sampling weight", hor  msymbol(dot) lwi()  mcolor(red) lcolor(red) lp(dash)),  ///
        title(Industry)  ytick(, grid) /*ylabel(1 "`: label (age_cat) 1'" 2 "`: label (age_cat) 2'" 3 "`: label (age_cat) 3'" 4 "`: label (age_cat) 4'", /// 
        labsize(small))*/ legend(pos(6) col(3)  order(1 "with sampling weight" 3 "without sampling weight")) ///
        ylabel() xtitle("Coefficient on Covid19 Pandemic", size(small)) xline(0, lc(black) lp(dash)) xlabel(-0.2(0.05)0.2) plotregion(margin(.1))  graphregion(color(white)) bgcolor(white)  xtit() ytit("", size(small))