I expected the calls below to viridis and hcl.color to output the same three colors:
> viridis::viridis(9) %>% sub("FF$", "", .)
[1] "#440154" "#472D7B" "#3B528B" "#2C728E" "#21908C" "#27AD81" "#5DC863" "#AADC32" "#FDE725"
> viridisLite::viridis(9) %>% sub("FF$", "", .)
[1] "#440154" "#472D7B" "#3B528B" "#2C728E" "#21908C" "#27AD81" "#5DC863" "#AADC32" "#FDE725"
> grDevices::hcl.colors(9, palette = "viridis")
[1] "#4B0055" "#403173" "#00588B" "#007B97" "#009B95" "#00B785" "#53CC67" "#B2DC3C" "#FDE333"
> colorspace::sequential_hcl(9, "Viridis")
[1] "#4B0055" "#403173" "#00588B" "#007B97" "#009B95" "#00B785" "#53CC67" "#B2DC3C" "#FDE333"
However, these functions generate slightly different colors:

Is this expected? What am I missing about the differences between these functions? Thanks!
The differences in colors between
viridisandhcl.colorswithpalette = "viridis"are expected because they operate in different color spaces, and the mapping between these spaces may not perfectly preserve the original colors. If you want to use the"viridis"palette, it's recommended to directly use theviridisfunction to ensure consistent and perceptually uniform colors.Edit:
viridistypically generates colors in theHSL(Hue, Saturation, Lightness) color space.hcl.colorgenerates colors in theHCL(Hue, Chroma, Luminance) color space.