1

The current ggbiplot (code below) shows X axis values from -5 to 5 and Y axis from -4 to 4. How can I change it so it will be X axis values from -6 to 6 and Y axis from -6 to 6?

Thanks.

Code:

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')
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
lroca
  • 621
  • 2
  • 8
  • 19

1 Answers1

3

One possibility: Use xlim and ylim fuctnions

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)
MYaseen208
  • 22,666
  • 37
  • 165
  • 309