Skip to content

Setting options(ggplot2.discrete.fill) overrides for aes(colour) with bad colourmap #4149

Closed
@apoorvalal

Description

@apoorvalal

I know the option to set colour palette is in its early stages, so wanted to flag an error I noticed.

Looks like setting ggplot2.discrete.fill overwrites the colourmap for colour (which should be unchanged based on the documentation?) with a cmap that is both ugly and unintelligible (and it hides the legend too for some reason).

``` r
library(ggplot2)
(p1 = ggplot(mpg, aes(class)) + geom_bar(aes(fill = drv)))

# unrelated plot 
(p2 = ggplot(mtcars, aes(x = wt,  y = mpg)) +
  geom_point(aes(colour = as.factor(cyl))))

# this should only apply to p1
options(ggplot2.discrete.fill    = function() scale_fill_viridis_d())
# as it does
p1

# but it also mysteriously overrides p2's colourmap 
p2

I'm running ggplot 3.3.2 in R 3.6.3 on a machine running ubuntu 18.04 LTS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorscales 🐍

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions