1

Hi I have made a ggbiplot with the example given in the package. I would like to know if it's possible to remove the grey background.

library(ggbiplot)

data(wine)

wine.pca <- prcomp(wine, scale. = TRUE)

print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE))

I have looked into the functions given here

https://github.com/vqv/ggbiplot/blob/master/R/ggbiplot.r

But as far as I can see none of these parameteres changes the background.

I am not experienced in R, but if someone has a solution for the wine example I am sure I can extrapolate to my own data.

Thank you very much!

user3637348
  • 29
  • 1
  • 5

3 Answers3

1

Something like this?

p <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE) + theme_bw()
print(p)
johannes
  • 14,043
  • 5
  • 40
  • 51
0

There are multiple options, but all of them include changing the "theme" somehow. It doesn't has anything to do with biplot, with with ggplot itself.

First, change only the background:

+ theme(panel.background = element_blank())

If you want to remove the grid lines as well:

+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

Further options are in ?theme

Second, you can change the total theme, for example:

+ theme_bw()  #black and white theme, as previously suggested
+ theme_classic(à  # classic theme

Or of course, you can combine both.

You can find further info here: http://felixfan.github.io/rstudy/2013/11/27/ggplot2-remove-grid-background-margin/

Wave
  • 1,216
  • 1
  • 9
  • 22
0

Nope, something like this:

p <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE) 
p + theme_bw()

or

p + theme_classic()

or

p + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

and so on and so forth.

arco444
  • 22,002
  • 12
  • 63
  • 67
RMenezes
  • 1
  • 1