作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
你好。我正在策划 pca
与 factoextra
包裹。我对每个因素有 3 分,并想在每个因素周围画椭圆。但我收到错误 Too few points to calculate an ellipse
.
可以在 ggplot2
中围绕 3 个点绘制椭圆与 stat_ellipse
功能。我可以通过查看 calculate_ellipse
来确认这一点code来自 ggplot2
那说else if (dfd < 3) {message("Too few points to calculate an ellipse")
.那么椭圆函数是什么factoextra
在 fviz_pca_ind
中使用它认为 3 分太少?有没有办法强制它添加省略号?该软件包具有我需要的特定功能,因此我想坚持使用它。谢谢。
library(factoextra)
data(iris)
iris2<-iris[c(1:3,51:53,101:103),] # 3 points for each factor
res.pca <- prcomp(iris2[, -5], scale = TRUE)
fviz_pca_ind(res.pca, label='none',alpha.ind = 1,
habillage=iris2$Species,
repel = TRUE,
addEllipses = TRUE,invisible='quali')+
theme(legend.position = 'bottom')+
coord_equal()
#Too few points to calculate an ellipse
#Too few points to calculate an ellipse
#Too few points to calculate an ellipse
最佳答案
我遇到了同样的问题。解决方案是使用 ggforce
中的 geom_mark_ellipse
包裹。可以围绕 3 个点(甚至围绕 1 个点)创建一个椭圆。
因此,工作流程应该如下:
library(factoextra)
library(ggforce)
data(iris)
iris2<-iris[c(1:3,51:53,101:103),] # 3 points for each factor
res.pca <- prcomp(iris2[, -5], scale = TRUE)
fviz_pca_ind(res.pca, label='none',alpha.ind = 1,
habillage=iris2$Species,
repel = TRUE,
# Don't use default Ellipses!!!!
# addEllipses = TRUE,
invisible='quali') +
# ADD ggforce's ellipses
ggforce::geom_mark_ellipse(aes(fill = Groups,
color = Groups)) +
theme(legend.position = 'bottom') +
coord_equal()
关于r - 错误 : Too few points to calculate an ellipse with 3 points?-R,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49931681/
我是一名优秀的程序员,十分优秀!