Learn R Programming

harrypotter (version 2.0.0)

scale_color_hp: Harry Potter colour scales

Description

Uses the Harry Potter color scale.

Usage

scale_color_hp(..., alpha = 1, begin = 0, end = 1, direction = 1,
  discrete = FALSE, house = "hufflepuff")

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

scale_colour_hp_d

scale_color_hp_d

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

scale_fill_hp_d

Arguments

...

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 house to use. Four houses are available: "Gryffindor", "Slytherin", "Ravenclaw" and "Hufflepuff".

Format

An object of class ScaleDiscrete (inherits from Scale, ggproto, gg) of length 16.

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.

Examples

Run this code
# NOT RUN {
library(ggplot2)

# ripped from the pages of ggplot2
ggplot(mtcars, aes(wt, mpg)) +
  geom_point(size=4, aes(colour = factor(cyl))) +
    scale_color_hp(discrete=TRUE, house = "Gryffindor") +
    theme_bw()

# ripped from the pages of ggplot2
dsub <- subset(diamonds, x > 5 & x < 6 & y > 5 & y < 6)
dsub$diff <- with(dsub, sqrt(abs(x-y))* sign(x-y))
ggplot(dsub, aes(x, y, colour=diff)) +
  geom_point() +
  scale_colour_hp(house = "Ravenclaw") +
  theme_bw()


# from the main hp example
dat <- data.frame(x = rnorm(10000), y = rnorm(10000))

ggplot(dat, aes(x = x, y = y)) +
  geom_hex() +
  coord_fixed() +
  scale_fill_hp(house = "Hufflepuff") +
  theme_bw()


# }

Run the code above in your browser using DataLab