Skip to contents

The `mediocre` palettes provide alternative default colors for ggplots. These functions enable to create such palettes. The main color palettes have been defined using https://coolors.co/.

Usage

palette_mediocre_d(pal = "autumn", second_pair = FALSE, gradient = NULL, ...)

palette_mediocre_c(pal = "autumn", gradient = NULL, ...)

Arguments

pal

a string. Defines the color palette selected. Can either be either "autumn", "rainbow", "green", "hotcold", "blackandwhite", "coty", "leo", "portal" or "pem"

second_pair

if true sets an alternative pair of colors for graphs with two colors

gradient

a string, either "left" or "right". Turns divergent palettes into gradient ones by splitting it in two. If equal to "right", the gradient palette is built with the right hand side part of the divergent palette. If equal to "left", uses the left hand side but flipping so that light values are on the left.

...

Other arguments passed on to discrete_scale, continuous_scale, or binned_scale to control name, limits, breaks, labels and so forth.

See also

Other color scales: scale_mediocre_d()

Other color scales: scale_mediocre_d()

Examples

palette_mediocre_d()
#> function (...) 
#> {
#>     colors_table <- mediocrethemes::colors_table
#>     color_theme <- colors_table[which(colors_table$pal == pal), 
#>         ]
#>     mediocre_color_vector <- unlist(strsplit(color_theme[["vector"]], 
#>         split = ", "))
#>     mediocre_color_four <- unlist(strsplit(color_theme[["four_colors"]], 
#>         split = ", "))
#>     if (!is.null(gradient) & !(pal %in% c("green", "blackandwhite"))) {
#>         if (gradient == "right") {
#>             mediocre_color_vector <- mediocre_color_vector[8:15]
#>         }
#>         else if (gradient == "left") {
#>             mediocre_color_vector <- rev(mediocre_color_vector[1:8])
#>         }
#>     }
#>     if (second_pair) {
#>         mediocre_color_four <- rev(mediocre_color_four)
#>     }
#>     mediocre_pal <- function(n) {
#>         if (is.null(gradient)) {
#>             if (n == 2) {
#>                 color_vector <- mediocre_color_four[1:2]
#>             }
#>             else if (n == 3) {
#>                 color_vector <- mediocre_color_four[-3]
#>             }
#>             else if (n == 4) {
#>                 color_vector <- mediocre_color_four
#>             }
#>             else {
#>                 color_vector <- mediocre_color_vector
#>             }
#>         }
#>         else {
#>             color_vector <- mediocre_color_vector
#>         }
#>         the_palette <- grDevices::colorRampPalette(color_vector)
#>         return(the_palette(n))
#>     }
#>     ggplot2::discrete_scale(..., aesthetics = c("fill", "color"), 
#>         scale_name = "disc_scale", palette = mediocre_pal, na.value = "gray91")
#> }
#> <bytecode: 0x1051a0a58>
#> <environment: 0x1051a7a88>

palette_mediocre_c(pal = "rainbow")
#> function (...) 
#> {
#>     colors_table <- mediocrethemes::colors_table
#>     color_theme <- colors_table[which(colors_table$pal == pal), 
#>         ]
#>     mediocre_color_vector <- unlist(strsplit(color_theme[["vector"]], 
#>         split = ", "))
#>     if (!is.null(gradient)) {
#>         if (gradient == "right") {
#>             mediocre_color_vector <- mediocre_color_vector[8:15]
#>         }
#>         else if (gradient == "left") {
#>             mediocre_color_vector <- rev(mediocre_color_vector[1:8])
#>         }
#>     }
#>     ggplot2::scale_fill_gradientn(..., colors = mediocre_color_vector, 
#>         aesthetics = c("fill", "color"), na.value = "gray91", 
#>         guide = guide_colourbar(theme = theme(legend.key.width = unit(5, 
#>             "cm"), legend.key.height = unit(0.25, "cm"), legend.ticks.length = unit(0.125, 
#>             "cm"), legend.title.position = "top", legend.margin = ggplot2::margin(t = -0.4, 
#>             unit = "cm"))))
#> }
#> <bytecode: 0x10521cac0>
#> <environment: 0x10521e5f0>