Skip to content

Instantly share code, notes, and snippets.

@PaulC91
Created February 16, 2023 17:41
Show Gist options
  • Save PaulC91/bf734fb3ed77540da7d94f7c858baacf to your computer and use it in GitHub Desktop.
Save PaulC91/bf734fb3ed77540da7d94f7c858baacf to your computer and use it in GitHub Desktop.
library(ggplot2)

scale_fill_msf <- function(...) {
  ggplot2:::manual_scale(
    "fill",
    values = c(
      "MSF" = "#D02327",
      "OCA" = "#EF5423",
      "OCB" = "#FFC70A",
      "OCBA" = "#0D9948",
      "OCG" = "#CB1C66",
      "OCP" = "#34469C",
      "WaCA" = "#007E92"
    ),
    ...
  )
}

ocs <- c("MSF", "OCA", "OCB", "OCBA", "OCG", "OCP", "WaCA")

df <- data.frame(
  oc = ocs,
  value = runif(length(ocs), 5, 10)
)

ggplot(df, aes(x = oc, y = value, fill = oc)) +
  geom_col() +
  scale_fill_msf()

Created on 2023-02-16 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment