【发布时间】:2019-06-30 11:30:29
【问题描述】:
我想在笛卡尔坐标x=0 和x=1 处绘制一条梯度非常陡峭的曲线。
我尝试根据斜率生成加权绘图点。 但我没有成功。
上图代码
# Plot points weighted for gradient (My attempt)
ll <- stats::rchisq(100, 1)
lll <- 0.99 + ll
l <- append(ll, lll)
# Definition of curve
x <- 1 - exp(-l)
y <- 1 - stats::pnorm(0.3*stats::qnorm( exp(-l) ) - 0.5)
# Curve through precisely at (x, y) = (0, 0) and (1, 1)
plot(x, y, xlim = c(0, 1), ylim = c(0, 1))
我想要的情节
编辑
使用@TavoGLC 的答案,我可以做出几乎完美的情节。在我的包中,y <- 1 - stats::pnorm(0.3*stats::qnorm( exp(-l) ) - 0.5)
定义中的数字0.3 和0.5 发生了变化,下面我使用0.13 和0.19 而不是0.3 和0.5。
【问题讨论】:
-
如果您将
x <- c(0, x, 1)与y结合起来,您将接近该图。 -
谢谢@RuiBarradas,但它只增加了两点
(0,0)和(1,1)。我想添加(0,0)和(1,1)附近的足够点 -
也许是
seq(0, min(x) - 0.01, length.out = 10)而不是0?从max(x)到1也是如此。 -
谢谢@RuiBarradas,但它不起作用,因为它增加了负 9 分。即使我可以添加正点,我认为它也无法绘制连接曲线。但从你的回复来看,我想我必须画一条连接
(0,0)和(min(x), min(y))的线