ggplot 4.0 personalized theme

I had a personalized theme used for nearly every graph in every project


    mcoe_theme <- list(ggthemes::theme_hc(),
                     ggthemes::scale_fill_few() ,
                     ggplot2::theme(plot.title.position = "plot"),
                     ggplot2::labs(x = "",
                          y = "",
                          fill ="") )

I can partially rewrite it as


mcoe_theme <- function() {
  ggthemes::theme_hc() +
    #    ggthemes::scale_fill_few() +
    theme(
      plot.title.position = "plot",
      palette.colour.discrete = c(
        "#88BDE6",
        "#FBB258",
        "#90CD97",
        "#F6AAC9",
        "#BFA554",
        "#BC99C7",
        "#EDDD46",
        "#F07E6E"
      )
      # axis.line = element_line(),
      # strip.background = element_blank()
    )
}

however I need to change all the existing graphs from + mcoe_theme to + mcoe_theme()

Is there a way to update my branding function in my organization package so that + mcoe_theme continues to work?

You might rewite it as

mcoe_theme <- ggthemes::theme_hc() +
    theme(
      plot.title.position = "plot",
      palette.colour.discrete = c(
        "#88BDE6",
        "#FBB258",
        "#90CD97",
        "#F6AAC9",
        "#BFA554",
        "#BC99C7",
        "#EDDD46",
        "#F07E6E"
      )
    )

but If you have to use a function, you could do

mcoe_theme_fun <- function() {
ggthemes::theme_hc() +
# ggthemes::scale_fill_few() +
theme(
plot.title.position = "plot",
palette.colour.discrete = c(
"#88BDE6",
"#FBB258",
"#90CD97",
"#F6AAC9",
"#BFA554",
"#BC99C7",
"#EDDD46",
"#F07E6E"
)
)
}

delayedAssign("mcoe_theme", mcoe_theme_fun())

ggplot(df)+
geom_line(aes(x, y)+
mcoe_theme