get_scale_color: Create the scale_color_ and scale_fill_ functions

Description Usage Arguments Value Examples

View source: R/scales.R

Description

This wil create the 'scale_color_' and 'scale_fill_' functions, to be applied in 'ggplot2'. It sets up the color palettes.

Usage

1
2
3
get_scale_color(pal_object)

get_scale_fill(pal_object)

Arguments

pal_object

The output of the 'get_pal' function.

palette_list

The list that contains the character vectors with color codes. List elements should be named.

Value

A function that can be used to create color scale in an object of class 'ggplot2'. The function has the following parameters:

'palette', a character that indicates which of the color vectors to use.

'alpha', the desired transparancy.

'reverse', if TRUE, the direction of the colours is reversed.

'discrete', whether to use a discrete colour palette.

'...“ additional arguments to pass to scale_color_gradientn

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# devtools::install_github("RopenScilabs/ochRe")
# devtools::install_github("EdwinTh/dutchmasters")
library(ggplot2)

ochRe_pal <- get_pal(ochRe::ochre_palettes)
scale_colour_ochRe <- get_scale_colour(ochRe::ochre_palettes,
                                      ochRe_pal)

dutchmasters_pal <- get_pal(dutchmasters::dutchmasters)
scale_fill_dutchmasters <- get_fill_colour(dutchmasters::dutchmasters,
                                           dutchmasters_pal)

ggplot(mtcars, aes(mpg, wt)) +
  geom_point(aes(colour = factor(cyl)), size = 4) +
  scale_colour_ochRe()
ggplot(mtcars, aes(mpg, wt)) +
  geom_point(aes(colour = hp)) +
  scale_colour_ochRe(palette = "lorikeet", discrete = FALSE)
ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y = hwy, color = class)) +
  scale_colour_dutchmasters(palette="view_of_Delft")
ggplot(diamonds) + geom_bar(aes(x = cut, fill = clarity)) +
  scale_fill_dutchmasters(palette = "anatomy")

EdwinTh/paletti documentation built on May 13, 2019, 10:59 p.m.