how keep aesthetic mapping but remove a specific item from legend with ggplot

Thank you, Mara -- this is very helpful! I didn't know it was possible to access the discrete palette directly.

Using your suggestion, here a modification that uses the limits argument) and does the job:

library(tidyverse)

my_colors <- scales::hue_pal()(3)
# add names so bar for 'c' gets fill, too
names(my_colors) <- letters[1:3] 

tibble(column = letters[1:3]) %>% 
  ggplot(aes(column)) +
  geom_bar(aes(fill = column)) +
  scale_fill_manual(
    values = my_colors,
    limits = c('a', 'b')
    )

Created on 2020-02-13 by the reprex package (v0.3.0)

2 Likes