Package 'tintin'

Title: 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>.
Authors: Mauricio Vargas Sepulveda [aut, cre]
Maintainer: Mauricio Vargas Sepulveda <[email protected]>
License: MIT + file LICENSE
Version: 0.2
Built: 2024-10-29 04:31:52 UTC
Source: https://github.com/pachadotdev/tintin

Help Index


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 ggplot2::discrete_scale(), ggplot2::continuous_scale(), or ggplot2::binned_scale() to control name, limits, breaks, labels and so forth.

alpha

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

begin

The (corrected) hue in ⁠[0,1]⁠ at which the color map begins.

end

The (corrected) hue in ⁠[0,1]⁠ at which the color map 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 color map option to use. Options are available:

  • "Tintin in the Land of the Soviets"

  • "Tintin in the Congo"

  • "Tintin in America"

  • "Cigars of the Pharaoh"

  • "The Blue Lotus" (Standard)

  • "The Broken Ear"

  • "The Black Island"

  • "King Ottokar's Sceptre"

  • "The Crab with the Golden Claws"

  • "The Shooting Star"

  • "The Secret of the Unicorn"

  • "Red Rackham's Treasure"

  • "The Seven Crystal Balls"

  • "Prisoners of the Sun"

  • "Land of Black Gold"

  • "Destination Moon"

  • "Explorers on the Moon"

  • "The Calculus Affair"

  • "The Red Sea Sharks"

  • "Tintin in Tibet"

  • "The Castafiore Emerald"

  • "Flight 714 to Sydney"

  • "Tintin and the Picaros"

  • "Tintin and Alph-Art"

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 colour and fill aesthetics at the same time, via aesthetics = c("colour", "fill").

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 na.translate = TRUE, what aesthetic value should the missing values be displayed as? Does not apply to position scales where NA is always placed at the far right.

guide

A function used to create a guide or its name. See guides() for more information.

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 (1\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 color map begins.

end

The (corrected) hue in ⁠[0,1]⁠ at which the color map 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 color map option to use. Options are available with tidy names (i.e., 'the_blue_lotus'):

"Tintin in the Land of the Soviets"
"Tintin in the Congo"
"Tintin in America"
"Cigars of the Pharaoh"
"The Blue Lotus" (Standard)
"The Broken Ear"
"The Black Island"
"King Ottokar's Sceptre"
"The Crab with the Golden Claws"
"The Shooting Star"
"The Secret of the Unicorn"
"Red Rackham's Treasure"
"The Seven Crystal Balls"
"Prisoners of the Sun"
"Land of Black Gold"
"Destination Moon"
"Explorers on the Moon"
"The Calculus Affair"
"The Red Sea Sharks"
"Tintin in Tibet"
"The Castafiore Emerald"
"Flight 714 to Sydney"
"Tintin and the Picaros"
"Tintin and Alph-Art"

Details

Check the README for the display of the color palettes. Semi-transparent colors (0<alpha<10 < 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 ⁠[0,1]⁠, see argument alpha in hsv.

begin

The (corrected) hue in ⁠[0,1]⁠ at which the color map begins.

end

The (corrected) hue in ⁠[0,1]⁠ at which the color map 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 color map option to use. Options are available:

  • "Tintin in the Land of the Soviets"

  • "Tintin in the Congo"

  • "Tintin in America"

  • "Cigars of the Pharaoh"

  • "The Blue Lotus" (Standard)

  • "The Broken Ear"

  • "The Black Island"

  • "King Ottokar's Sceptre"

  • "The Crab with the Golden Claws"

  • "The Shooting Star"

  • "The Secret of the Unicorn"

  • "Red Rackham's Treasure"

  • "The Seven Crystal Balls"

  • "Prisoners of the Sun"

  • "Land of Black Gold"

  • "Destination Moon"

  • "Explorers on the Moon"

  • "The Calculus Affair"

  • "The Red Sea Sharks"

  • "Tintin in Tibet"

  • "The Castafiore Emerald"

  • "Flight 714 to Sydney"

  • "Tintin and the Picaros"

  • "Tintin and Alph-Art"

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