最近我在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))
提前感谢您!
geom_label_repel
中添加show.legend = FALSE
即可取消图例显示 ;) - dc37