如何在 qqnorm 图中获取 x 轴的值

How do I get the value of the x-axis in qqnorm plot

我正在尝试使用 plotly.js 和在 R 中获得的值来制作标准 qqplot。

我可以获得 y 轴值。

m <- lm(Sepal.Length ~ Sepal.Width + Petal.Width, data=iris)
plot(m, which=2) #this plot is what I want to make using plotly
std.resi <- rstandard(m) # y-axis values

但是,有问题。 我不知道如何获取 x 轴值。

请多多指教。 谢谢。

x 轴包含高斯分布的分位数。

所以,假设你有 N 个点,你可以通过以下方式获得 x 轴的值:

a <- (1:N+1)/(N+1) #get N equally spaced values between 0 and 1
a <- a[c(-(N+1))] #remove value at 1
quant <- qnorm(a) #obtain gaussian quantiles

希望对您有所帮助!

非常感谢。我得到了 x 轴值。

std.resi
N <- length(std.resi)
a_2 <- 1:(N+1) / (N+1)
a_2<- a_2[c(-(N+1))]
std.resi.sort <- sort(std.resi)
quant <- qnorm(a_2)
plot(quant, std.resi.sort)