{"id":16284659,"url":"https://github.com/pachadotdev/tintin","last_synced_at":"2025-03-20T02:31:15.589Z","repository":{"id":185169736,"uuid":"628878823","full_name":"pachadotdev/tintin","owner":"pachadotdev","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.","archived":false,"fork":false,"pushed_at":"2024-08-29T15:23:01.000Z","size":7509,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T22:41:08.580Z","etag":null,"topics":["ggplot2","ggplot2-scales","r"],"latest_commit_sha":null,"homepage":"https://pacha.dev/tintin","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pachadotdev.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-17T07:06:34.000Z","updated_at":"2024-12-06T15:32:12.000Z","dependencies_parsed_at":"2024-08-29T16:58:16.116Z","dependency_job_id":"295d9238-a9dc-46fa-b4d4-fb6dec62aeb6","html_url":"https://github.com/pachadotdev/tintin","commit_stats":null,"previous_names":["pachadotdev/tintin"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pachadotdev%2Ftintin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pachadotdev%2Ftintin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pachadotdev%2Ftintin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pachadotdev%2Ftintin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pachadotdev","download_url":"https://codeload.github.com/pachadotdev/tintin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244043304,"owners_count":20388560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ggplot2","ggplot2-scales","r"],"created_at":"2024-10-10T19:20:18.809Z","updated_at":"2025-03-20T02:31:13.488Z","avatar_url":"https://github.com/pachadotdev.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  echo = TRUE,\n  message = FALSE,\n  warning = FALSE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# tintin \u003cimg src=\"man/figures/logo.svg\" align=\"right\" height=\"139\" alt=\"\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/tintin)](https://CRAN.R-project.org/package=tintin)\n\u003c!-- badges: end --\u003e\n\nThe goal of tintin is to provide 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.\n\n```{r pallettes, echo=FALSE, fig.width=7, fig.height=7}\nshowcol \u003c- function (pal = rev(tintin::tintin_colours), n = NULL, type = \"all\", exact.n = TRUE) {\n  gaplist \u003c- \"\"\n\n  maxnum \u003c- 5\n\n  palattr \u003c- switch(type, qual = \"qualitative\", div = \"divergent\",\n                    seq = \"sequential\", all = \"qualitative+divergent+sequential\")\n  if (is.null(n))\n    n \u003c- maxnum\n\n  if (length(n) == 1)\n    n \u003c- rep(n, length(pal))\n\n  n[n \u003c 3] \u003c- 3\n  n[n \u003e maxnum] \u003c- maxnum[n \u003e maxnum]\n  nr \u003c- length(pal)\n  nc \u003c- max(n)\n  ylim \u003c- c(0, nr)\n  oldpar \u003c- par(mgp = c(2, 0.25, 0))\n  on.exit(par(oldpar))\n  plot(1, 1, xlim = c(-4, nc), ylim = ylim, type = \"n\", axes = FALSE,\n       bty = \"n\", xlab = \"\", ylab = \"\")\n  for (i in 1:nr) {\n    nj \u003c- n[i]\n    if (pal[i] == \"\")\n      next\n    shadi \u003c- pal[[i]]\n    rect(xleft = 0:(nj - 1), ybottom = i - 1, xright = 1:nj,\n         ytop = i - 0.2, col = shadi, border = \"light grey\")\n  }\n  text(rep(-0.1, nr), (1:nr) - 0.6, labels = names(pal), xpd = TRUE,\n       adj = 1)\n}\n\nshowcol()\n```\n\n## Installation\n\nYou can install the released version of tintin from [CRAN](https://CRAN.R-project.org) with:\n\n``` r\ninstall.packages(\"tintin\")\n```\n\nYou can install the development version of tintin like so:\n\n``` r\nremotes::install_github(\"pachadotdev/tintin\")\n```\n\n## Example\n\nThis is a basic example which shows you how to create a plot. We'll plot\nthe top five causes of injury in the `tintin_head_trauma` dataset that comes \nwith the package.\n\n```{r example1}\nlibrary(dplyr)\nlibrary(ggplot2)\nlibrary(tintin)\n\ntotal_head_trauma_5 \u003c- tintin_head_trauma %\u003e% \n  arrange(-loss_of_consciousness_length) %\u003e% \n  filter(row_number() \u003c= 5)\n\nggplot(total_head_trauma_5) +\n  geom_col(aes(x = cause_of_injury, y = loss_of_consciousness_length, \n    fill = book_title), position = \"dodge\") +\n  labs(x = \"Cause of injury\", y = \"Loss of consciousness length\",\n    title = \"Top five causes of injury\") +\n  theme_minimal() +\n  scale_fill_manual(values = tintin_colours$the_black_island,\n    name = \"Book\") +\n  coord_flip()\n```\n\nWhat is special about the package is being able to pass the colours as a \nfunction to `ggplot2`. We'll adapt the previous example to show that case.\n\n```{r example2}\nggplot(total_head_trauma_5) +\n  geom_col(aes(x = cause_of_injury, y = loss_of_consciousness_length, \n    fill = book_title), position = \"dodge\") +\n  labs(x = \"Cause of injury\", y = \"Loss of consciousness length\",\n    title = \"Top five causes of injury\") +\n  theme_minimal() +\n  scale_fill_tintin_d(option = \"cigars_of_the_pharaoh\", direction = -1) +\n  coord_flip()\n```\n\n```{r example2_2, eval = FALSE}\n# Note that I can also write the palette name as\n# \"cigars of the pharaoh\" or even as \"CiGaRS  of ThE Pharaoh\"\nggplot(total_head_trauma_5) +\n  geom_col(aes(x = cause_of_injury, y = loss_of_consciousness_length, \n    fill = book_title), position = \"dodge\") +\n  labs(x = \"Cause of injury\", y = \"Loss of consciousness length\",\n    title = \"Top five causes of injury, again\") +\n  theme_minimal() +\n  scale_fill_tintin_d(option = \"cigars of the pharaoh\", direction = -1) +\n  coord_flip()\n```\n\nWhat happens if we need more colours than 5? The functions in the package\ncan fix that. We'll plot the top ten causes of injury.\n\n```{r example3}\ntotal_head_trauma_10 \u003c- tintin_head_trauma %\u003e% \n  arrange(-loss_of_consciousness_length) %\u003e% \n  filter(row_number() \u003c= 10)\n\nggplot(total_head_trauma_10) +\n  geom_col(aes(x = cause_of_injury, y = loss_of_consciousness_length, \n    fill = book_title), position = \"dodge\") +\n  labs(x = \"Cause of injury\", y = \"Loss of consciousness length\",\n    title = \"Top ten causes of injury\") +\n  scale_fill_manual(values = tintin_clrs(\n    n = length(unique(total_head_trauma_10$book_title)), \n    option = \"the black island\"),\n    name = \"Book\") +\n  coord_flip()\n```\n\n```{r example3_2, eval = FALSE}\n# or alternatively\n\nggplot(total_head_trauma_10) +\n  geom_col(aes(x = cause_of_injury, y = loss_of_consciousness_length, \n    fill = book_title), position = \"dodge\") +\n  labs(x = \"Cause of injury\", y = \"Loss of consciousness length\",\n    title = \"Top ten causes of injury\") +\n  scale_fill_manual(values = tintin_pal(option = \"the black island\")(8), \n    name = \"Book\") +\n  coord_flip()\n```\n\nThe use of colour instead of fill is analogous. Let's plot the top ten causes of\ninjury per year to see it.\n\n```{r example4}\nlibrary(tidyr)\n\ntotal_head_trauma_y \u003c- tintin_head_trauma %\u003e% \n  group_by(year) %\u003e% \n  summarise_if(is.integer, sum) %\u003e% \n  pivot_longer(loss_of_consciousness_length:loss_of_consciousness_severity) %\u003e%\n  mutate(\n    name = ifelse(name == \"loss_of_consciousness_length\", \"Length\", \"Severity\")\n  )\n\nggplot(total_head_trauma_y) +\n  geom_line(aes(x = year, y = value, color = name), linewidth = 1.5) +\n  labs(x = \"Year\", y = \"Intensity\",\n    title = \"Loss of consciousness length and severity\") +\n  theme_minimal() +\n  scale_colour_manual(\n    values = tintin_pal(option = \"tintin in the land of the soviets\")(2), \n    name = \"Cause of injury\"\n  )\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpachadotdev%2Ftintin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpachadotdev%2Ftintin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpachadotdev%2Ftintin/lists"}