为什么 ggplot 忽略 R 中的指南命令?

Ant*_*nko 2 graphics r ggplot2

在下面的示例中,ggplot尽管使用 command 绘制图例guides(fill=FALSE)。而且,它guides完全无视。例如,您不能按列排列图例。

为什么会发生这种情况以及如何在这种情况下控制图例?

dfg = data.frame(category=sample(c("A", "B"), 10, replace=T),
                     name=sample(c("x", "y"), 10, replace=T),
                     clients=rnorm(10),
                     rating=rnorm(10))
ggplot(dfg, aes(x = clients, y = rating, color=category, label=name)) +
  geom_text(hjust=0.5, vjust=0.5) +
  guides(fill=FALSE)
Run Code Online (Sandbox Code Playgroud)

Rol*_*and 5

fill您的情节中没有指南。看起来你想要guides(colour=FALSE)

指南的类型对应于您在其中指定的内容,aes并且您没有在fill那里映射颜色。