Type: Package
Title: Palettes Generated from All "Harry Potter" Movies
Version: 2.1.1
Maintainer: Alejandro Jimenez Rico <aljrico@gmail.com>
Description: Implementation of characteristic palettes inspired in the Wizarding World and the Harry Potter movie franchise.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: TRUE
Depends: R (≥ 2.10)
Suggests: hexbin (≥ 1.27.0), testthat (≥ 2.1.0)
URL: https://github.com/aljrico/harrypotter
BugReports: https://github.com/aljrico/harrypotter/issues
Imports: ggplot2 (≥ 1.0.1), gridExtra
RoxygenNote: 7.0.2
NeedsCompilation: no
Packaged: 2020-03-04 20:09:10 UTC; Alejandro
Author: Alejandro Jimenez Rico [aut, cre], Alfredo Hernandez [ctb]
Repository: CRAN
Date/Publication: 2020-03-05 05:40:06 UTC

Harry Potter Colour Map.

Description

This function creates a vector of n equally spaced colors along the 'HP colour map' of your selection

Usage

hp(
  n,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  option = "Always",
  house = NULL
)

hp_pal(
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  option = "Always",
  house = NULL
)

harrypotter(
  n,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  option = "Always",
  house = NULL
)

Arguments

n

The number of colors (\ge 1) to be in the palette.

alpha

The alpha transparency, a number in [0,1], see argument alpha in hsv.

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 ordered from darkest to lightest. If -1, the order of colors is reversed.

option

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

house

Depcreated. Use 'option' instead.

Details

Semi-transparent colors (0 < alpha < 1) are supported only on some devices: see rgb.

Value

hp returns a character vector, cv, of color hex codes. This can be used either to create a user-defined color palette for subsequent graphics by palette(cv), a col = specification in graphics functions or in par.

Author(s)

Alejandro Jiménez Rico aljrico@gmail.com, Personal Blog

Examples

library(ggplot2)
library(hexbin)

dat <- data.frame(x = rnorm(1e4), y = rnorm(1e4))
ggplot(dat, aes(x = x, y = y)) +
  geom_hex() +
  coord_fixed() +
  scale_fill_gradientn(colours = hp(128, option = 'Always'))

pal <- hp(256, option = "Ravenclaw")
image(volcano, col = pal)


Original 'Harry Potter' colour map

Description

A dataset containing some colour palettes inspired on the Harry Potter Universe

Usage

hp.map

Format

A data frame containing all the colours used in the palette:


Available Palettes.

Description

This list contains all the available palettes in the 'harrypotter' package.

Usage

hp_palettes

Format

A list containing all palettes color codes.


Harry Potter colour scales

Description

Uses the Harry Potter color scale.

Usage

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

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")