To plot the empirical cumulative density of three variables, x1, x2 and x3, I used the following in r:
plot.ecdf(x1, col="blue",
main="Distribution XYZ",
xlab="x_i", ylab="Prob(x_i<=y)")
lines(ecdf(x2), col="red") # adds a line
lines(ecdf(x3), col="green") # adds line
legend(600,0.6, # places a legend from (x,y)=(600,0.6) on
c("x1","x2","x3"), # puts text in the legend
lty=c(1,1,1), # gives the legend appropriate symbols (lines)
lwd=c(1,1,1),col=c("blue","red","green")) # gives the legend lines the correct color and width
The resulting plot however has two horizontal lines (broken lines) at 0 and 1 besides the box. And, the origin of the box has a space below zero on the vertical axis and a space to the left of zero on the horizontal axis. May you suggest how to remove these space and the additional lines. I wanted but could not post the plot.
EDITED: A sample data can be generated as follows:
n <- 1000; u <- runif(n)
a <- -4.46; b <- 1.6; c <- -4.63
d <- ( a * u ) + (b * ( ( 1.5 * ( u ** 2 )) - 0.5 )) + (c * ( (2.5 * (u ** 3)) - (1.5 * u )))
x1 <- -126/d; x2 <- -131/d; x3 <- -187/d
It sounds like you are asking for the style provided by different settings for 'xaxs' and 'yaxs', and maybe 'xlim':
Try:
plot.ecdf(x1, col="blue",
main="Distribution XYZ",
xlab="x_i", ylab="Prob(x_i<=y)",
xaxs="i",yaxs="i", xlim=c(0,1000) )
lines(ecdf(x2), col="red")
lines(ecdf(x3), col="green")
legend(600,0.6,
c("x1","x2","x3"),
lty=c(1,1,1),
lwd=c(1,1,1),col=c("blue","red","green"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With