Title: | Tintin Palette Generator |
Version: | 0.2 |
Description: | Palettes generated from Tintin covers. There is one palette per cover, with a total of 24 palettes of 5 colours each. Includes functions to interpolate colors in order to create more colors based on the provided palettes.The data is based on Cyr, et al. (2004) <doi:10.1503/cmaj.1041405> and Wikipedia https://en.wikipedia.org/wiki/The_Adventures_of_Tintin. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.1 |
Depends: | R (≥ 2.10) |
LazyData: | true |
Imports: | dplyr, ggplot2, magrittr, rlang, scales, tidyr |
Suggests: | spelling |
Language: | en-US |
NeedsCompilation: | no |
Packaged: | 2024-08-25 16:20:49 UTC; pacha |
Author: | Mauricio Vargas Sepulveda
|
Maintainer: | Mauricio Vargas Sepulveda <m.sepulveda@mail.utoronto.ca> |
Repository: | CRAN |
Date/Publication: | 2024-08-29 15:20:02 UTC |
tintin: Tintin Palette Generator
Description
Palettes generated from Tintin covers. There is one palette per cover, with a total of 24 palettes of 5 colours each. Includes functions to interpolate colors in order to create more colors based on the provided palettes.The data is based on Cyr, et al. (2004) doi:10.1503/cmaj.1041405 and Wikipedia https://en.wikipedia.org/wiki/The_Adventures_of_Tintin.
Author(s)
Maintainer: Mauricio Vargas Sepulveda m.sepulveda@mail.utoronto.ca (ORCID)
Pipe operator
Description
See magrittr::%>%
for details.
Usage
lhs %>% rhs
Arguments
lhs |
A value or the magrittr placeholder. |
rhs |
A function call using the magrittr semantics. |
Value
The result of calling rhs(lhs)
.
Tintin Colour Scales
Description
The tintin
scales provide colour maps for the different Tintin
covers.
Usage
scale_colour_tintin_d(
...,
alpha = 1,
begin = 0,
end = 1,
direction = 1,
option = "the_blue_lotus",
aesthetics = "colour"
)
scale_colour_tintin_c(
...,
alpha = 1,
begin = 0,
end = 1,
direction = 1,
option = "the_blue_lotus",
values = NULL,
na.value = "grey50",
guide = "colourbar",
aesthetics = "colour"
)
scale_fill_tintin_d(
...,
alpha = 1,
begin = 0,
end = 1,
direction = 1,
option = "the_blue_lotus",
aesthetics = "fill"
)
scale_fill_tintin_c(
...,
alpha = 1,
begin = 0,
end = 1,
direction = 1,
option = "the_blue_lotus",
values = NULL,
na.value = "grey50",
guide = "colourbar",
aesthetics = "fill"
)
Arguments
... |
Other arguments passed on to |
alpha |
The alpha transparency, a number in |
begin |
The (corrected) hue in |
end |
The (corrected) hue in |
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 color map option to use. Options are available:
|
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
values |
if colours should not be evenly positioned along the gradient this vector gives the position (between 0 and 1) for each colour in the colours vector. |
na.value |
If |
guide |
A function used to create a guide or its name. See
|
Value
A ggproto
object for use with ggplot2
.
Examples
library(dplyr)
library(ggplot2)
library(tintin)
total_head_trauma <- tintin_head_trauma %>%
arrange(-loss_of_consciousness_length) %>%
filter(row_number() <= 5)
# discrete scale
ggplot(total_head_trauma) +
geom_col(aes(x = cause_of_injury, y = loss_of_consciousness_length,
fill = book_title), position = "dodge") +
labs(x = "Cause of injury", y = "Loss of consciousness length",
title = "Top five causes of injury") +
theme_minimal() +
scale_fill_tintin_d(option = "cigars_of_the_pharaoh", direction = -1) +
coord_flip()
# continuous scale
# continuous scale
ggplot(total_head_trauma) +
geom_col(aes(
x = cause_of_injury, y = loss_of_consciousness_length,
fill = year
), position = "dodge") +
labs(
x = "Cause of injury", y = "Loss of consciousness length",
title = "Top five causes of injury"
) +
theme_minimal() +
scale_fill_tintin_c(option = "cigars_of_the_pharaoh", direction = -1)
Tintin Colour Palettes
Description
This function creates a vector of colours along the selected colour map.
Usage
tintin_clrs(
n = 5,
alpha = 1,
begin = 0,
end = 1,
direction = 1,
option = "the_blue_lotus"
)
Arguments
n |
The number of colors ( |
alpha |
The alpha transparency, a number in |
begin |
The (corrected) hue in |
end |
The (corrected) hue in |
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 color map option to use. Options are available with tidy names (i.e., 'the_blue_lotus'):
|
Details
Check the README for the display of the color palettes.
Semi-transparent colors (0 < alpha < 1
) are supported only on some
devices (see rgb
).
Value
A character
vector of colors.
Examples
# without extrapolation: 5 or fewer colors
n <- 5
tintin_clrs(n, option = "the_blue_lotus")
image(
1:n, 1, as.matrix(1:n),
col = tintin_clrs(n, option = "the_blue_lotus"),
xlab = "Tintin darkblue n", ylab = "", xaxt = "n", yaxt = "n", bty = "n"
)
# with extrapolation: 6 or more colors
n <- 20
image(
1:n, 1, as.matrix(1:n),
col = tintin_clrs(n, option = "the_blue_lotus"),
xlab = "Tintin darkblue n", ylab = "", xaxt = "n", yaxt = "n", bty = "n"
)
Tintin Colours
Description
A list with 23 vectors (one per Tintin book) containing the five most frequent colors per cover. White tones were removed to balance the palettes. Alph-Art is Herge's unfinished book, it was published posthumously, so we don't consider it in the list.
Usage
tintin_colours
Format
A list with 23 vectors.
Source
Tintin covers obtained from Wikipedia and processed with ImageMagick.
Examples
head(tintin_colours)
Tintin Head Trauma
Description
Neurological traumas sustained by the subject (by book title)
Usage
tintin_head_trauma
Format
A data frame with 50 rows and 4 variables
Details
year
Release year of the comic, first occurrence was used for titles with a b&w and colour edition
book_title
English title of the books
page
Page number where the traumas happen
cause_of_injury
What causes the trauma (i.e., explosion)
loss_of_consciousness_length
Loss of consciousness length measured by the number of cartoon frames before subject returns to normal activity.
loss_of_consciousness_severity
Loss of consciousness severity measured by the number of objects revolving above Tintin's head
Source
Cyr, Antoine, Louis-Olivier Cyr, and Claude Cyr. "Acquired growth hormone deficiency and hypogonadotropic hypogonadism in a subject with repeated head trauma, or Tintin goes to the neurologist." CMAJ 171, no. 12 (2004): 1433-1434. The book release year was obtained from Wikipedia.
Examples
tintin_head_trauma
Tintin Colour Palettes
Description
A wrapper function around Tintin_clrs
to
turn it into a palette function compatible with
discrete_scale
.
Usage
tintin_pal(
alpha = 1,
begin = 0,
end = 1,
direction = 1,
option = "the_blue_lotus"
)
Arguments
alpha |
The alpha transparency, a number in |
begin |
The (corrected) hue in |
end |
The (corrected) hue in |
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 color map option to use. Options are available:
|
Details
See Tintin_clrs
for more information on the color palettes.
Value
A function that takes an integer argument and returns a character
vector of colors.
Examples
tintin_pal()
scales::show_col(tintin_pal()(5))