rggplot2ggbiplot

ggbiplot - change the point size


Does someone have an idea how to change the point size and still maintain the group colors in the code below?

Just adding the geom_point(size = 8) changes the colors of all the points to black.

Code:

library(ggbiplot)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
g <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, 
              groups = wine.class, varname.size = 8, labels.size=10  , ellipse = TRUE, circle = TRUE)
g <- g + scale_color_discrete(name = '') #+  geom_point(size = 8)
g <- g + opts(legend.direction = 'horizontal', 
              legend.position = 'top')
print(g)

Solution

  • Adding a color aesthetic inside geom_point will keep the points colored by group. Also, I changed opts to theme, since opts has been deprecated.

    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')