Skip to content

NA key does not show up in legend when colour limits include NA #5749

Closed
@davidhodge931

Description

@davidhodge931
library(palmerpenguins)
library(tidyverse)

penguins |>
  ggplot() +
  geom_point(
    aes(x = flipper_length_mm, 
        y = body_mass_g,
        col = species)) +
  scale_colour_manual(values = c("red", "blue"), limits = c("Adelie", "Gentoo"))
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).

penguins |>
  ggplot() +
  geom_histogram(
    aes(x = flipper_length_mm, 
        fill = species)) +
  scale_fill_manual(values = c("red", "blue"), limits = c("Adelie", "Gentoo"))
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_bin()`).

Created on 2024-03-06 with reprex v2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorscales 🐍

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions