scale_hp: Harry Potter colour scales

Description Usage Arguments Details Author(s) Examples

Description

Uses the Harry Potter color scale.

Usage

 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
scale_color_hp(
  option = "Always",
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  discrete = FALSE,
  house = NULL
)

scale_colour_hp(
  option = "Always",
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  discrete = FALSE,
  house = NULL
)

scale_colour_hp_d(
  option = "Always",
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1
)

scale_color_hp_d(
  option = "Always",
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1
)

scale_fill_hp_d(
  option = "Always",
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1
)

scale_fill_hp(
  option = "Always",
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  discrete = FALSE,
  house = NULL
)

Arguments

option

A character string indicating the colourmap to use. Four houses are available: "Gryffindor", "Slytherin", "Ravenclaw" and "Hufflepuff".

...

parameters to discrete_scale or scale_fill_gradientn

alpha

pass through parameter to hp

begin

The (corrected) hue in [0,1] at which the hp colormap begins.

end

The (corrected) hue in [0,1] at which the hp colormap ends.

direction

Sets the order of colors in the scale. If 1, the default, colors are as output by hp_pal. If -1, the order of colors is reversed.

discrete

generate a discrete palette? (default: FALSE - generate continuous palette)

house

A character string indicating the colourmap from a option to use. This parameter is deprectaed, 'option' should be used instead. Four houses are available: "Gryffindor", "Slytherin", "Ravenclaw" and "Hufflepuff".

Details

For discrete == FALSE (the default) all other arguments are as to scale_fill_gradientn or scale_color_gradientn. Otherwise the function will return a discrete_scale with the plot-computed number of colors.

Author(s)

Alejandro Jiménez Rico aljrico@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
library(ggplot2)



ggplot(mtcars, aes(factor(cyl), fill=factor(vs))) +
geom_bar() +
scale_fill_hp(discrete = TRUE, option = "Ravenclaw")

ggplot(mtcars, aes(factor(gear), fill=factor(carb))) +
geom_bar() +
scale_fill_hp(discrete = TRUE, option = "Slytherin")

ggplot(mtcars, aes(x = mpg, y = disp, colour = hp)) +
geom_point(size = 2) +
scale_colour_hp(option = "Gryffindor")

harrypotter documentation built on March 13, 2020, 9:09 a.m.