我們可以做到以下幾點。我對代碼的評論非常具有說服力。
## reproducible example
set.seed(0)
cdecn <- sample(1:10,570,replace=TRUE)
a <- rnorm(cdecn,mean(cdecn),sd(cdecn)) ## random samples
a <- sort(a) ## sort samples in ascending order
e_cdf <- ecdf(a) ## ecdf function
e_cdf_val <- 1:length(a)/length(a) ## the same as: e_cdf_val <- e_cdf(a)
par(mfrow = c(1,2))
## ordinary ecdf plot
plot(a, e_cdf_val, type = "s", xlab = "ordered samples", ylab = "ECDF",
main = "ECDF")
## switch axises to get 'inverse' ECDF
plot(e_cdf_val, a, type = "s", xlab = "ECDF", ylab = "ordered sample",
main = "'inverse' ECDF")
## where the curve intersects 0
p <- e_cdf(0)
## [1] 0.01578947
## highlight the intersection point
points(p, 0, pch = 20, col = "red")
## add a dotted red vertical line through intersection
abline(v = p, lty = 3, col = "red")
## display value p to the right of the intersection point
## round up to 4 digits
text(p, 0, pos = 4, labels = round(p, 4), col = "red")

不,不需要刪除您的答案!我只是想知道你是否有更好的方法來添加直線。我終於找到了一些東西,但可能不是很直接。 –
切換軸的繪圖是我正在尋找的。我將添加第二條曲線到曲線,我想說明曲線之間的差異。所以我需要一個垂直線穿過點(x,0)。在這種情況下,我會想要一個大致x = 0.05的垂直線。所以我的問題是如何確定這一點。 – Dylan