Skip to content

Binned scales don't use na.value #3867

Closed

Description

@andrewheiss

The new binned scales in v3.3.0 don't appear to use na.value, though na.value is included in the documentation (?scale_fill_steps) and ostensibly has a default of grey50.

Here's a reprex. scale_fill_gradient() works with na.value, but binned scales like scale_fill_viridis_b() and scale_fill_steps() do not:

library(ggplot2)
library(dplyr)

df <- tibble(x = rep(1:3, 2), y = rep(1:2, 3), z = 1:6) %>% 
  mutate(z = ifelse(x == 1 & y == 1, NA, z))

p <- ggplot(df, aes(x = x, y = y)) +
  geom_tile(aes(fill = z))

p + scale_fill_gradient(na.value = "red")

p + scale_fill_viridis_b(na.value = "red")

p + scale_fill_steps(na.value = "red")

Activity

  1. yutannihilation commented on Mar 8, 2020

    @yutannihilation
    Member

    Thanks for reporting! Fixed in the dev version. But, I don't think we'll plan a patch release soon unless there found some serious issue in version 3.3.0... Sorry for inconvenience.

  2. thomasp85 commented on Mar 8, 2020

    @thomasp85
    Member

    We will probably have a pretty speedy release in the not too distant future

  3. yutannihilation commented on Mar 8, 2020

    @yutannihilation
    Member

    Oh, really? I see!

  4. smouksassi commented on Mar 10, 2020

    @smouksassi

    while currently, continuous scales do not show NA in the legend discrete scales do. How would the person looking at the plot know that what is shown as "red" or other color is missing? IMHO a good legend should decode everything shown in the plot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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