考虑到以下代码使用了通过devtools::install.github()提供的ggbiplot库:
library(ggbiplot)
data(iris)
log.ir <- log(iris[, 1:4])
ir.species <- iris[, 5]
ir.pca <- prcomp(log.ir, center = TRUE, scale. = TRUE)
g <- ggbiplot(ir.pca, obs.scale = 1, var.scale = 1, groups = ir.species)
g <- g + theme(legend.direction = 'vertical', legend.position = 'right')
g <- g + scale_color_manual(values=c("blue", "red", "green"))
print(g)根据分组自定义数据点边界的最佳方法是什么?我使用scale_color_manual()来自定义这些数据点的颜色,但是我想不出有什么方法可以用于边框。
谢谢
发布于 2016-11-02 20:07:23
假设你想调整数据点本身的边框.
ggbiplot()调用本身不会给您提供这种灵活性,但是设置alpha = 0将使ggbiplot绘制的点变得不可见或实际上100%透明。然后,您可以使用geom_point()调用创建一个单独的层,其中指定shape为具有填充(中间)和颜色(边框)美学的5个形状(21-25)之一。
ggbiplot(ir.pca, obs.scale = 1, var.scale = 1, groups = ir.species, alpha = 0) +
theme(legend.direction = 'vertical', legend.position = 'right') +
scale_color_manual(values=c("blue", "red", "green")) +
scale_fill_manual(values = c("red", "green", "blue")) + # just offset by one to show
geom_point(size = 3, shape = 21, aes(fill = groups, color = groups))

在您的问题中包含您使用的包只能通过devtools::install.github()获得,而不是标准的install.packages()。
https://stackoverflow.com/questions/40387366
复制相似问题