如何防止R ggplot在图例中显示 "a" 符号?

4

最近我在R中使用ggplot绘制了一个图。当我添加ggplot_label_repel的代码后,突然图例中的符号从圆圈变成了字母"a"。

这与wingdings字体有关吗?如何修复我的图例?

我在此提供了一些可重现错误的示例代码:

#packages
library(dplyr)
library(ggplot2)
library(ggrepel)
#Creating an example data frame
years <- c(1990:1999)
population <- c(1:10)
df <- tibble(years,population)

#Adding random information to the df so that I can do coloring and labeling on my ggplot
df$group <- "low population"
df[8:10, 3] <- "high population"
df$status <- "highly endangered"
df$status[3:5] <- "endangered"
df$status[5:7] <- "threatened"
df$status[8:10] <- "recovered"

#The ggplot with the legend I want
ggplot(df, aes(years,population, color= group))+
  geom_point()

#The ggplot with the labeling I want but the wrong legend
ggplot(df, aes(years,population, color= group))+
  geom_point()+
  geom_label_repel(data=df %>% filter(group =="high population"),
                   aes(label= status))

提前感谢您!


5
geom_label_repel 中添加 show.legend = FALSE 即可取消图例显示 ;) - dc37
1个回答

3

在geom_label_repel()中添加show.legend = F参数:

ggplot(df, aes(years,population, color= group))+
  geom_point()+
  geom_label_repel(data=df %>% filter(group =="high population"),
                   aes(label= status),show.legend  = F)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接