Hi, I am struggling plotting multiple CDFs in one graph and zooming in for certain data range. I'm getting stairsteps but I want smooth lines. I got the distribution of A1c but want to show the graph zooming in for A1c<6. it is giving me very weird stairsteps graph. here is the code I'm using:
***generating CDF for 7 time periods
foreach wave of numlist 1 2 3 4 5 6 7{
cumul a1c [aw=svyweight_yr] if wave ==`wave', gen(Fa1c`wave')}
***plotting multiple CDFs if A1c<6
scalar Target_level = 5.7
twoway (scatter Fa1c1 a1c, sort connect(J) lw(thin) lc(pink) ms(none)) ///
(scatter Fa1c2 a1c, sort connect(J) lw(thin) lc(blue) ms(none)) ///
(scatter Fa1c3 a1c, sort connect(J) lw(thin) lc(orange) ms(none)) ///
(scatter Fa1c4 a1c, sort connect(J) lw(thin) lc(green) ms(none)) ///
(scatter Fa1c5 a1c, sort connect(J) lw(thin) lc(purple) ms(none)) ///
(scatter Fa1c6 a1c, sort connect(J) lw(thin) lc(black) ms(none)) ///
(scatter Fa1c7 a1c, sort connect(J) lw(thin) lc(red) ms(none)) ///
if a1c<6 , xline(`=Target_level', lwidth(1pt) lcolor(green)) xtitle(Glycohemoglobin (%)) legend(label( 1 "1988-1991") label(2 "1992-1994") label(3 "1999-2002") label(4 "2003-2006") label(5 "2007-2010") label(6 "2011-2014") label(7 "2015-2018") rows(2) size(small))
If I use "distplot" and fix the range A1c <6, it will not give me whole distribution. I need whole distribution but zooming in up to 6.
It would be really helpful if anyone could please help me sorting this issue. Thanks in advance.
***generating CDF for 7 time periods
foreach wave of numlist 1 2 3 4 5 6 7{
cumul a1c [aw=svyweight_yr] if wave ==`wave', gen(Fa1c`wave')}
***plotting multiple CDFs if A1c<6
scalar Target_level = 5.7
twoway (scatter Fa1c1 a1c, sort connect(J) lw(thin) lc(pink) ms(none)) ///
(scatter Fa1c2 a1c, sort connect(J) lw(thin) lc(blue) ms(none)) ///
(scatter Fa1c3 a1c, sort connect(J) lw(thin) lc(orange) ms(none)) ///
(scatter Fa1c4 a1c, sort connect(J) lw(thin) lc(green) ms(none)) ///
(scatter Fa1c5 a1c, sort connect(J) lw(thin) lc(purple) ms(none)) ///
(scatter Fa1c6 a1c, sort connect(J) lw(thin) lc(black) ms(none)) ///
(scatter Fa1c7 a1c, sort connect(J) lw(thin) lc(red) ms(none)) ///
if a1c<6 , xline(`=Target_level', lwidth(1pt) lcolor(green)) xtitle(Glycohemoglobin (%)) legend(label( 1 "1988-1991") label(2 "1992-1994") label(3 "1999-2002") label(4 "2003-2006") label(5 "2007-2010") label(6 "2011-2014") label(7 "2015-2018") rows(2) size(small))
If I use "distplot" and fix the range A1c <6, it will not give me whole distribution. I need whole distribution but zooming in up to 6.
It would be really helpful if anyone could please help me sorting this issue. Thanks in advance.
Comment