Skip to content

Passing name to fill and colour scales as unnamed first argument is broken in 4.0.0 #6623

@dmphillippo

Description

@dmphillippo

Fill and colour scales no longer seem to support passing name as the first unnamed argument after v4.0.0.

ggplot(mtcars, aes(x = disp, y = hp, size = gear, colour = wt, fill = factor(cyl))) +
  geom_point(shape = 21) +
  scale_fill_discrete("Cylinders") +    # Fill and colour scales are affected
  scale_colour_continuous("Weight") +   # Both discrete and continuous
  scale_size_continuous("Gears")        # Some(?) other scales are not

Expecting the legend labels “Cylinders” and “Weight”. Explicitly passing name gives the expected result.

ggplot(mtcars, aes(x = disp, y = hp, size = gear, colour = wt, fill = factor(cyl))) +
  geom_point(shape = 21) +
  scale_fill_discrete(name = "Cylinders") +
  scale_colour_continuous(name = "Weight") +
  scale_size_continuous("Gears")

This does not seem to affect all types of scales - e.g. size and alpha seem fine (I haven't checked them all!).

Created on 2025-09-18 with reprex v2.1.1

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