sjmgarnier / viridis

Colorblind-Friendly Color Maps for R
http://sjmgarnier.github.io/viridis
Other
286 stars 38 forks source link

Supplying aesthetics in scale_color_viridis does not work #88

Closed alanocallaghan closed 1 year ago

alanocallaghan commented 1 year ago

Runs into #> Error in self$palette(n): attempt to apply non-function.

Reprex:

library("ggplot2")
library("viridis")
#> Loading required package: viridisLite

# works
ggplot(mtcars) +
    aes(wt, mpg, color = cyl) +
    geom_point() +
    scale_color_viridis()


# works
ggplot(mtcars) +
    aes(wt, mpg, color = cyl) +
    geom_point() +
    scale_color_viridis(aesthetics = "color")


# works
ggplot(mtcars) +
    aes(wt, mpg, color = factor(cyl)) +
    geom_point() +
    scale_color_viridis(discrete=TRUE)


# does not work
ggplot(mtcars) +
    aes(wt, mpg, color = factor(cyl)) +
    geom_point() +
    scale_color_viridis(discrete=TRUE, aesthetics = "color")
#> Error in self$palette(n): attempt to apply non-function

# works
ggplot(mtcars) +
    aes(wt, mpg, color = factor(cyl)) +
    geom_point() +
    scale_color_brewer()


# works
ggplot(mtcars) +
    aes(wt, mpg, color = factor(cyl)) +
    geom_point() +
    scale_color_brewer(aesthetics = "color")

sjmgarnier commented 1 year ago

Fixed with #89. Thanks for the PR.