Skip to content

Could scale_*_manual have a default values argument of NULL? #5653

Closed as not planned
@davidhodge931

Description

@davidhodge931

The scale_*_manual functions are super useful. Is it possible that the values argument in these could default to NULL? This would allow users familiar with them to use them to change other non-values aspects of the scale through these functions

library(tidyverse)

p <- ggplot(mtcars, aes(mpg, wt)) +
  geom_point(aes(colour = factor(cyl)))

#you can do this currently
p + 
  scale_colour_manual(values = c("red", "blue", "green"),
                      breaks = c(4, 6))

#I would like to be able to do this
p + 
  scale_colour_manual(breaks = c(4, 6))
#> Error in `palette()`:
#> ! Insufficient values in manual scale. 3 needed but only 0 provided.

Created on 2024-01-20 with reprex v2.1.0

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