How do I stop R ggplot from displaying "a" as the symbol in my legend? [duplicate]
Asked Answered
L

1

6

Recently I made a plot using ggplot in R. When I add my code for ggplot_label_repel, suddenly the symbols in the legend change from circles into the letter "a".

Does this have something to do with wingdings font? How do I fix my legend?

I have made some example code with the reproducible error here:

#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))

Thank you in advance!

Lovable answered 31/3, 2020 at 18:35 Comment(1)
add show.legend = FALSE into geom_label_repel ;)Genarogendarme
A
5

add ,show.legend =F to geom_label_repel()

like this:

ggplot(df, aes(years,population, color= group))+
  geom_point()+
  geom_label_repel(data=df %>% filter(group =="high population"),
                   aes(label= status),show.legend  = F)
Animality answered 31/3, 2020 at 18:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.