[英]How to change loading labels of biplot in r?
I am struggling with changing the loading labels of biplot.我正在努力更改双标图的加载标签。 I used prcomp function to run PCA and ggbiplot.我使用 prcomp function 来运行 PCA 和 ggbiplot。 I've tried to change it with loading.label.label = c("a","b","c","d")
, but it didn't work.我试图用loading.label.label = c("a","b","c","d")
改变它,但它没有用。 I have attached my code and plot below.我在下面附上了我的代码和 plot。
k <- kmeans(comp,2)
TW$Group <- factor(k$cluster)
pca2 <- prcomp(TW[,c(7,11,18,19)], center = TRUE, scale. = TRUE)
summary(pca2)
pca2
cc <- c("a","b","c","d")
library(ggbiplot)
p <- ggbiplot(pca2, group = TW$Group, ellipse = TRUE,loadings.label.repel = TRUE) +
ggrepel::geom_text_repel(aes(colour = TW$Group, label = paste(TW$P,TW$Box)), size = 2.5)+
theme_minimal() +
xlim(-2.5,2.5) + ylim(-2.5,3.5) + theme(legend.position = c(0.9, 0.9))
plot(p)
Not sure you can do this with the ggbiplot
function.不确定您是否可以使用ggbiplot
function 执行此操作。 A workaround would be to change the names in the pca
object like this:一种解决方法是更改pca
object 中的名称,如下所示:
library(ggbiplot)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
rownames(wine.pca$rotation) <- rep("my_names", length(wine.pca$center))
print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.