Skip to content

legend key does not respect scale_fill_manual(..., drop = FALSE) #5586

Closed
@davidhodge931

Description

@davidhodge931

In the below example, the legend key for female should be red with a black border.

I'm using the latest DEV version of ggplot2. It works correctly in 3.4.4.

library(tidyverse)
library(palmerpenguins)

penguins |>
  mutate(sex = factor(sex)) |>
  filter(sex == "male") |>
  ggplot() +
  geom_violin(aes(
    x = sex,
    y = body_mass_g,
    fill = sex,
  )) +
  scale_fill_manual(values = c("red", "blue"), drop = FALSE)

Created on 2023-12-15 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions