看来你需要改变ggbiplot
功能略。类型ggbiplot
在控制台中,将代码复制到编辑器中。在里面arglist
in the function
,为箭头的颜色、线型和透明度(“alpha”)添加“名称 = 表达式”术语。
ggbiplot2 <- function (pcobj, choices = 1:2, scale = 1, pc.biplot = TRUE,
obs.scale = 1 - scale, var.scale = scale, groups = NULL,
ellipse = FALSE, ellipse.prob = 0.68, labels = NULL, labels.size = 3,
alpha = 1, var.axes = TRUE, circle = FALSE, circle.prob = 0.69,
varname.size = 3, varname.adjust = 1.5, varname.abbrev = FALSE,
color = muted("red"), # <- add new arguments to the function
linetype = "solid",
alpha_arrow = 1)
然后搜索geom_segment
部分,并添加参数color
, linetype
and alpha
:
g <- g + geom_segment(data = df.v, aes(x = 0, y = 0, xend = xvar, yend = yvar),
arrow = arrow(length = unit(1/2, "picas")),
color = color, linetype = linetype, alpha = alpha_arrow)
将编辑后的函数指定为新名称,例如ggbiplot2
。尝试一下,设置箭头默认值以外的值:
ggbiplot2(pca, obs.scale = 1, var.scale = 1, groups = class, circle = F, varname.size = 1, varname.adjust = 6,
color = "blue", linetype = "dashed", alpha_arrow = 0.5) # <- use the new arguments