1

嗨,我用包中给出的例子做了一个 ggbiplot。我想知道是否可以删除灰色背景。

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

我已经研究了这里给出的功能

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

但据我所见,这些参数都没有改变背景。

我在 R 方面没有经验,但如果有人有葡萄酒示例的解决方案,我相信我可以推断出我自己的数据。

非常感谢你!

4

3 回答 3

1

像这样的东西?

p <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE) + theme_bw()
print(p)
于 2014-12-12T12:45:32.590 回答
0

有多个选项,但所有选项都包括以某种方式更改“主题”。它与 biplot 和 ggplot 本身没有任何关系。

首先,只改变背景:

+ theme(panel.background = element_blank())

如果您还想删除网格线:

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

更多选项在 ?theme

其次,您可以更改总主题,例如:

+ 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/

于 2014-12-12T13:03:07.603 回答
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.

于 2014-12-12T17:03:01.410 回答