Skip to content

scale_gradient's palette argument cannot be specified #6365

Closed
@twest820

Description

@twest820

Needed to set the direction on a gradient, which the docs indicate is can be done by setting palette.

That's broken, though. Looks like lack of checking for an existing palette argument somewhere along the call stack leads to a second palette getting inserted.

ggplot() +
  geom_point(aes(x = seq(0, 10), y = seq(0, 10), color = seq(0, 10))) +
  scale_color_gradient(palette = scales::pal_brewer(direction = -1))
Error in continuous_scale(aesthetics, name = name, palette = pal_seq_gradient(low,  : 
  formal argument "palette" matched by multiple actual arguments

A basic workaround looks to be call the scale directly and give those values to high and low though, depending on the gradient being used, that can compromise perceptual uniformity.

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