davidhodge931 / ggblanket

Simplify ggplot2 visualisation
https://davidhodge931.github.io/ggblanket/
Other
156 stars 8 forks source link

`col_palette`: ordinal vars should accept a vector of colours #866

Closed davidhodge931 closed 5 months ago

davidhodge931 commented 5 months ago
library(ggdist)
library(ggblanket)

stat_lineribbon()
#> geom_lineribbon: orientation = NA, na.rm = FALSE
#> stat_lineribbon: .width = c(0.5, 0.8, 0.95), point_interval = median_qi, orientation = NA, na.rm = FALSE
#> position_identity

set_blanket()

#should work but doesn't
data.frame(x = 1:10, y = rnorm(1000, 1:10)) |> 
  gg_blanket(
    geom = "lineribbon",
    stat = ggdist:::StatLineribbon,
    x = x, 
    y = y,
    col_palette = viridis::mako(n = 9)[c(5,7,9)],
    colour = viridis::mako(n = 9)[c(1)],
  )
#> Error in self$palette(n): attempt to apply non-function

#works
data.frame(x = 1:10, y = rnorm(1000, 1:10)) |> 
  gg_blanket(
    geom = "lineribbon",
    stat = ggdist:::StatLineribbon,
    x = x, 
    y = y,
    col_palette = scales::pal_viridis(option = "G", direction = -1, begin = 0.3),
    colour = viridis::mako(n = 9)[c(1)],
  )

Created on 2024-05-18 with reprex v2.1.0