combination_palette: Combine Color Palettes

Description Usage Arguments Details Value See Also Examples

View source: R/palettes.R

Description

This function uses dynamic arguments (...) in order to combine multiple color palettes together.

Usage

1

Arguments

...

You can use any name for your arguments, but the values must be a named list. The list can only have 4 named members:

palette

This is a palette function that returns a vector of colors.

args

This is another named list used for the palette function parameters.

range

This is a range (1:10) used to subset the color palette vector.

rev

This is a logical (TRUE/FALSE) used to reverse the color palette.

You can add as many parameters you want in order to combine as many color palettes as you want.

Details

This function allows you to combine a varying number of color palettes and gives you the ability to subset and reverse the palettes that are supplied.

Value

The output of this function is another function (grDevoces::colorRampPalette), which takes a number to generate an interpolated color palette as a character vector.

See Also

colorRamp

Other Color Palettes: get_color_palette, scico_palette, viridis_magma_palette, viridis_palette

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Not run: 
if(interactive()){
# Below is the code for the viridis_magma_palette function.
# It's a good example of how to use the combination_palette function.
viridis_magma_palette <- function(viridis_number = 800,
                                  viridis_range = 300:viridis_number,
                                  viridis_rev = TRUE,
                                  magma_number = 500,
                                  magma_range = 0:magma_number,
                                  magma_rev = FALSE,
                                  ...) {
    if (!missing(...)){
        v_args = list(n=viridis_number, ...)
        m_args = list(n=magma_number, ...)
    } else {
        v_args = list(n=viridis_number)
        m_args = list(n=magma_number)
        }
   crp <- combination_palette(viridis =
                                list(palette = viridis::viridis,
                                      args = v_args,
                                      range = viridis_range,
                                      rev = viridis_rev),
                               magma =
                                 list(palette = viridis::magma,
                                      args = m_args,
                                      range = magma_range,
                                      rev = magma_rev)
                               )
 return(crp)
}
 }

## End(Not run)

vallenderlab/MicrobiomeR documentation built on Aug. 30, 2019, 11:24 p.m.