1

当前的ggbiplot(下面的代码)显示了从-5到5的X轴值和从-4到4的Y轴。我怎样才能改变它,使它成为从-6到6的X轴值和从-6到6的Y轴?

谢谢。

代码:

library(devtools)
install_github("ggbiplot", "vqv")
library(ggbiplot)
data(wine)

ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class,
         varname.size = 8, labels.size=10, 
         ellipse = TRUE, circle = TRUE) +
  scale_color_discrete(name = '') +  
  geom_point(aes(colour=wine.class), size = 8) +
  theme(legend.direction ='horizontal', 
        legend.position = 'top')
4

1 回答 1

2

一种可能性:使用xlimylim功能

library(ggbiplot)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
p <-
ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class,
         varname.size = 8, labels.size=10,
         ellipse = TRUE, circle = TRUE) +
  scale_color_discrete(name = '') +
  geom_point(aes(colour=wine.class), size = 8) +
  theme(legend.direction ='horizontal',
        legend.position = 'top')
p <- p + xlim(-6, 6) + ylim(-6, 6)
print(p)
于 2014-06-08T09:12:59.917 回答