| Title: | Palettes Generated from All "Harry Potter" Movies |
|---|---|
| Description: | Implementation of characteristic palettes inspired in the Wizarding World and the Harry Potter movie franchise. |
| Authors: | Alejandro Jimenez Rico [aut, cre], Alfredo Hernandez [ctb] |
| Maintainer: | Alejandro Jimenez Rico <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.1.1 |
| Built: | 2026-05-31 08:17:45 UTC |
| Source: | https://github.com/aljrico/harrypotter |
This function creates a vector of n equally spaced colors along the
'HP colour map' of your selection
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 )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 )
n |
The number of colors ( |
alpha |
The alpha transparency, a number in [0,1], see argument alpha in
|
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. |
Semi-transparent colors () are supported only on some
devices: see rgb.
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.
Alejandro Jiménez Rico [email protected], Personal Blog
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)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)
This list contains all the available palettes in the 'harrypotter' package.
hp_paletteshp_palettes
A list containing all palettes color codes.
A dataset containing some colour palettes inspired on the Harry Potter Universe
hp.maphp.map
A data frame containing all the colours used in the palette:
V1: Red value
V2: Green value
V3: Blue value
option: It is intended to be a general option for choosing the specific colour palette.
Uses the Harry Potter color scale.
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 )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 )
option |
A character string indicating the colourmap to use. Four houses are available: "Gryffindor", "Slytherin", "Ravenclaw" and "Hufflepuff". |
... |
parameters to |
alpha |
pass through parameter to |
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 |
discrete |
generate a discrete palette? (default: |
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". |
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.
Alejandro Jiménez Rico [email protected]
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")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")