首页 > 解决方案 > 关于在 R 中绘制椭圆的问题

问题描述

我试图绘制椭圆,但似乎中心的长度有问题..它说中心的长度应该是 2,不知道这是什么意思,因为我尝试了长度(中心)它正好是 2.. 有没有人知道如何解决吗?提前致谢:)

l2<-c(141, 140, 145, 146, 150, 142, 139)
l3<-c(157, 168, 162, 159, 158, 140, 171)
l4<-c(168, 174, 172, 176, 168, 178, 176)
l5<-c(183, 170, 177, 171, 175, 189, 175)
a.mat<-matrix(c(l3-l2,l5-l4), 7, 2)
dbar<-matrix(c(16, 4), 2, 1)

library(ellipse)
n<-7
p<-4
S<-var(a.mat)
plot(ellipse(S,centre=dbar,t=sqrt(((n-1)*p/(n*(n-p)))*qf(0.95,p,n-p))),type="l",xlim=c(-40,60),ylim=c(-40,40), 
     main="95% Confidence Ellipse for \nSuccessive Yearly Length Increases \nYear3-Year2 and Year5-Year4", xlab = "Year3-Year2",
     ylab = "Year5-Year4")

错误显示为:

  centre must be a vector of length 2```

Then I tried:
> length(centre)
[1] 2



标签: rplot

解决方案


推荐阅读