问题
I am using R 3.4.3, and plotting the following function:
x = rnorm(5000,20,30)
cdf_1 <- ecdf(x)
plot(cdf_1, xlabs="x0",
ylabs="y0")
This gives me the following plot:
Now, the plot doesn't take the given labels x0 and y0. How to solve this?
Also, how do I get the value of x for y=0.95. I have tried using label names, but it throws error. Kindly suggest.
回答1:
The arguments for the labels are xlab
and ylab
(you added an extra s
in both):
To find x
for a y
of 0.95 you can do:
x[which(cdf_1(x) == 0.95)]
#[1] 68.38452
来源:https://stackoverflow.com/questions/48205568/how-to-find-the-x-value-given-the-y-value-from-a-plot-in-r