Skip to content

Instantly share code, notes, and snippets.

@MaximeWack
Last active November 28, 2017 13:23
Show Gist options
  • Save MaximeWack/c687e7a3a797eec1e22d1e7a3440f297 to your computer and use it in GitHub Desktop.
Save MaximeWack/c687e7a3a797eec1e22d1e7a3440f297 to your computer and use it in GitHub Desktop.
Color/fill functions for ggplot2 with my palette
my_scale_color_discrete <- function(n)
{
pal <- scales::colour_ramp(c("#192440", "#F05440"))
seq(0, 1, length.out = n) %>%
lapply(pal) %>%
unlist -> values
scale_color_manual(values = values, na.value = "#D2D2D2")
}
my_scale_fill_discrete <- function(n)
{
pal <- scales::colour_ramp(c("#192440", "#F05440"))
seq(0, 1, length.out = n) %>%
lapply(pal) %>%
unlist -> values
scale_fill_manual(values = values, na.value = "#D2D2D2")
}
my_scale_color_continuous <- function()
{
pal <- scales::colour_ramp(c("#192440", "#F05440"))
scale_color_continuous(low = pal(0), high = pal(1), na.value = "#D2D2D2")
}
my_scale_fill_continuous <- function()
{
pal <- scales::colour_ramp(c("#192440", "#F05440"))
scale_fill_continuous(low = pal(0), high = pal(1), na.value = "#D2D2D2")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment