Skip to content

Could the scale_*_steps* functions support applying the full range of colour provided? #6068

Closed
@davidhodge931

Description

@davidhodge931

The scale_*_steps* functions currently do not apply the full range of colours to a plot.

See example below of scale_colour_binned, which applies the full range of the viridis colour palette compared to adding viridis colours to scale_colour_stepsn which does not.

Generally, you need as big a range of colour as possible when colouring a numeric variable.

Could the scale_*_steps* functions apply the full range of colour by default to the plot?

library(tidyverse)
library(palmerpenguins)
library(patchwork)

p1 <- penguins |>
  ggplot() +
  geom_point(aes(x = flipper_length_mm, y = body_mass_g, col = flipper_length_mm, )) +
  scale_colour_binned(type = "viridis") +
  labs(title = "binned")

p2 <- penguins |>
  ggplot() +
  geom_point(aes(x = flipper_length_mm, y = body_mass_g, col = flipper_length_mm, )) +
  scale_colour_stepsn(colours = viridis::viridis(9)) +
  labs(title = "stepsn")

p1 + p2
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).
#> Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).

Created on 2024-09-01 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions