Last active
November 28, 2017 13:23
-
-
Save MaximeWack/c687e7a3a797eec1e22d1e7a3440f297 to your computer and use it in GitHub Desktop.
Color/fill functions for ggplot2 with my palette
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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