最近,我在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))
先感谢您!
将,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)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句