
This function creates a vector of n
equally spaced colors along the
'HP colour map' created by an average calculated for all the colours present in every frame of the pictures.
hpMap(n = 256, alpha = 1, begin = 0, end = 1, direction = 1,
house = "hufflepuff")hp(n, alpha = 1, begin = 0, end = 1, direction = 1,
house = "hufflepuff")
hp_pal(alpha = 1, begin = 0, end = 1, direction = 1,
house = "hufflepuff")
harrypotter(n, alpha = 1, begin = 0, end = 1, direction = 1,
house = "hufflepuff")
The number of colors (
The alpha transparency, a number in [0,1], see argument alpha in
hsv
.
The (corrected) hue in [0,1] at which the hp colormap begins.
The (corrected) hue in [0,1] at which the hp colormap ends.
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.
A character string indicating the colourmap from a house to use. Four houses are available: "Gryffindor", "Slytherin", "Ravenclaw" and "Hufflepuff".
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
.
hpMap
returns a n
lines data frame containing the
red (R
), green (G
), blue (B
) and alpha (alpha
)
channels of n
equally spaced colors along the 'Harry Potter' colour map.
n = 256
by default.
Here are the color scales:
Semi-transparent colors (rgb
.
# NOT RUN {
library(ggplot2)
library(hexbin)
dat <- data.frame(x = rnorm(10000), y = rnorm(10000))
ggplot(dat, aes(x = x, y = y)) +
geom_hex() + coord_fixed() +
scale_fill_gradientn(colours = hp(256, house = "Hufflepuff"))
# using code from RColorBrewer to demo the palette
n = 200
image(
1:n, 1, as.matrix(1:n),
col = hp(n, house = "Slytherin"),
xlab = "hp n", ylab = "", xaxt = "n", yaxt = "n", bty = "n"
)
# }
Run the code above in your browser using DataLab