我正在使用ggbiplot(),并希望操作数据点的颜色和形状,使它们对打印机更友好。目前我从ggbiplot()中得到了默认的彩虹颜色。我尝试过使用参数"+ scale_colour_discrete“和"+ scale_shape_manual”,但是"groups=“参数ggbiplot似乎覆盖了它们。如果我去掉"groups=“参数,那么椭圆就不能被画出来。"+主题“参数可以很好地工作。我的代码如下。我知道在常规的biplot()函数中可以更容易地操作颜色/形状,但我喜欢ggbiplot()提供的置信区间椭圆。
g <- ggbiplot(size.pca, choices=1:2, obs.scale = 1, var.scale = 1,
groups=fieldnames, ellipse = TRUE,ellipse.prob=0.68, varname.size=4)
g <- g + scale_colour_discrete(name=" ") #only the name=" " part of this seems to work.
g <- g + scale_shape_manual(values=c(17,16,16,16,16,16), name= " ") #trying to indicate one population different from the rest, but it doesn't seem to do anything (no error either, just no change in the output).
g <- g + theme_bw() +theme(legend.direction = 'horizontal',
legend.position = 'top')
print(g)发布于 2015-10-31 21:09:26
向您的ggplot脚本和scale_color_manual添加一个geom_point()参数,以覆盖组的默认颜色,而不会像下面这样更改分组向量:
g <- ggbiplot(size.pca, choices=1:2, obs.scale = 1, var.scale = 1,
groups=fieldnames, ellipse = TRUE,ellipse.prob=0.68, varname.size=4) +
geom_point(aes(colour = fieldnames), size = "your size") +
scale_color_manual(values=c(17,16,16,16,16,16)) +
theme_bw() +theme(legend.direction = 'horizontal',
legend.position = 'top')
print(g)这应该行得通!
https://stackoverflow.com/questions/30088686
复制相似问题