Skip to content

Change in behaviour of manual scales in release candidate #3727

Closed
@paleolimbot

Description

@paleolimbot

In previous ggplot2 versions, the following was valid:

library(ggplot2)
df <- data.frame(x = 1:3, y = 1:3)
ggplot(df, aes(x, y, col = factor(x))) +  
  geom_point() +
  scale_colour_manual(values = c("red", "green", "blue", "teal"), breaks = factor(1))

In the release candidate, it errors (revdep failures on at least auditor, ezplot, GDCRNATools, ggmuller, obAnalytics, RAM)

library(ggplot2)
df <- data.frame(x = 1:3, y = 1:3)
ggplot(df, aes(x, y, col = factor(x))) +  
  geom_point() +
  scale_colour_manual(values = c("red", "green", "blue", "teal"), breaks = factor(1))
#> Error:   Differing number of values and breaks in manual scale.
#>   4 values provided compared to 1 breaks.

Shouldn't the number of values line up with the number limits instead of the breaks? Otherwise, how would you map colours and not include them on the guide (niche behaviour, but it's possible with other colour scales)?

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