I am trying to create a custom color palette using hex codes and use it for the "fill" aesthetic (discrete variable) for geom_bar.
Please see code below.
library(pacman)
p_load(tidyverse, ggplot2, RColorBrewer)
palette_new <- colorRampPalette(colors = c("white", "#154360", "#FF5733", "#FFC300", "#1ABC9C"))(5)
scales::show_col(palette)
data(diamonds)
ggplot(diamonds, aes(x = color, fill = cut)) +
geom_bar() +
scale_fill_brewer(palette = "palette_new")
Output, but see error message below:
Warning message: In pal_name(palette, type) : Unknown palette palette_new
I have seen several questions about this on stack overflow and have tried different things that do not work. Thank you in advance!