gpt4 book ai didi

r - 如何在R图中将轴从零原点开始调整

转载 作者:行者123 更新时间:2023-12-03 21:24:05 25 4
gpt4 key购买 nike

为了绘制三个变量x1,x2和x3的经验累积密度,我在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


但是,结果图除了方框外,在0和1处还有两条水平线(虚线)。并且,盒子的原点在垂直轴上有一个零以下的空间,在水平轴上有一个零左的空间。可能您建议如何删除这些空间和其他行。我想要但无法发布情节。

编辑:
可以如下生成样本数据:

样本数据

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

最佳答案

听起来您正在要求由“ xaxs”和“ yaxs”(甚至是“ xlim”)的不同设置提供的样式:

尝试:

 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"))

关于r - 如何在R图中将轴从零原点开始调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17427717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com