Hi,
I am trying to plot two (or more) cdf's in a single graph. I prefer the form of a stairstep connected line and I am trying the following options but I get only one out of the cdf's properly connected.
The levels also in the y-axis are not correct.
1- I am getting the line connection properly for both line graphs but not when I try to combine them in a single graph
cumul x if y==1, gen(cumy1)
sort cumy1
line cumy1 x, sort c(J) m(J)
cumul x if y==0, gen(cumy0)
sort cumy0
line cumy0 x, c(J) m(J)
twoway (line cumy1 x, sort c(J) m(J)) (line cumy0 y, c(J) m(J))
2- Similar unsuccessful attempt when I try to use "line || line" etc.
cumul x if y==1, gen(cumy1)
sort cumy1
line cumy1 x, sort c(J) m(J)
cumul x if y==0, gen(cumy0)
sort cumy0
line cumy0 x, c(J) m(J)
line cumy1 x, sort c(J) m(J) || line cumy0 y, c(J) m(J)
3- Using the "stack" command
cumul x if y==1, gen(cumy1)
cumul x if y==0, gen(cumy0)
stack cumy1 x if y==1 cumy0 x if y==0, into(x y) wide clear
line cumy1 cumy0 x, c(J J) m(J J) sort ylab(, grid) ytitle("") xlab(, grid)
I have tried as well to first sort x and y and later on generate the cumulative function with a similar result.
I also would like to add features as lcolor(black) lpattern(dash) graphregion(color(white)) bgcolor(white) aspect(1), titles of y-axis and x-axis but I am posting above only simple versions of my code as I need to get first the cdf's properly plotted. However, if I am not mistaken, I double the options if "stack" is used i.e. lcolor(black black) lpattern(dash solid) while using separately in the case of a "twoway line" or "line || line" graph type, right ?
Any particular help on how I can such an unified graph would be appreciated.
Thank you,
Sotia
I am trying to plot two (or more) cdf's in a single graph. I prefer the form of a stairstep connected line and I am trying the following options but I get only one out of the cdf's properly connected.
The levels also in the y-axis are not correct.
1- I am getting the line connection properly for both line graphs but not when I try to combine them in a single graph
cumul x if y==1, gen(cumy1)
sort cumy1
line cumy1 x, sort c(J) m(J)
cumul x if y==0, gen(cumy0)
sort cumy0
line cumy0 x, c(J) m(J)
twoway (line cumy1 x, sort c(J) m(J)) (line cumy0 y, c(J) m(J))
2- Similar unsuccessful attempt when I try to use "line || line" etc.
cumul x if y==1, gen(cumy1)
sort cumy1
line cumy1 x, sort c(J) m(J)
cumul x if y==0, gen(cumy0)
sort cumy0
line cumy0 x, c(J) m(J)
line cumy1 x, sort c(J) m(J) || line cumy0 y, c(J) m(J)
3- Using the "stack" command
cumul x if y==1, gen(cumy1)
cumul x if y==0, gen(cumy0)
stack cumy1 x if y==1 cumy0 x if y==0, into(x y) wide clear
line cumy1 cumy0 x, c(J J) m(J J) sort ylab(, grid) ytitle("") xlab(, grid)
I have tried as well to first sort x and y and later on generate the cumulative function with a similar result.
I also would like to add features as lcolor(black) lpattern(dash) graphregion(color(white)) bgcolor(white) aspect(1), titles of y-axis and x-axis but I am posting above only simple versions of my code as I need to get first the cdf's properly plotted. However, if I am not mistaken, I double the options if "stack" is used i.e. lcolor(black black) lpattern(dash solid) while using separately in the case of a "twoway line" or "line || line" graph type, right ?
Any particular help on how I can such an unified graph would be appreciated.
Thank you,
Sotia
Comment