如何阻止 R ggplot 将“a”显示为图例中的符号?

liz*_*izs 5 r legend ggplot2 geom-text

最近,我在 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))
Run Code Online (Sandbox Code Playgroud)

先感谢您!

use*_*545 3

添加 ,show.legend =F 到 geom_label_repel()

像这样:

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