{"id":13857380,"url":"https://github.com/teunbrand/ggchromatic","last_synced_at":"2025-04-11T13:38:02.604Z","repository":{"id":103975956,"uuid":"329685767","full_name":"teunbrand/ggchromatic","owner":"teunbrand","description":"Colour and fill scales for 'ggplot2' using colour spaces.","archived":false,"fork":false,"pushed_at":"2021-02-24T21:56:59.000Z","size":2361,"stargazers_count":13,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T09:52:50.700Z","etag":null,"topics":["colors","ggplot-extension","ggplot2","ggplot2-scales"],"latest_commit_sha":null,"homepage":"https://teunbrand.github.io/ggchromatic/","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/teunbrand.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"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}},"created_at":"2021-01-14T17:23:34.000Z","updated_at":"2024-12-11T09:08:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"4231fad9-beae-4bb5-a6eb-9ba3f2ea8d1b","html_url":"https://github.com/teunbrand/ggchromatic","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teunbrand%2Fggchromatic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teunbrand%2Fggchromatic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teunbrand%2Fggchromatic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teunbrand%2Fggchromatic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teunbrand","download_url":"https://codeload.github.com/teunbrand/ggchromatic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248410358,"owners_count":21098775,"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":["colors","ggplot-extension","ggplot2","ggplot2-scales"],"created_at":"2024-08-05T03:01:35.053Z","updated_at":"2025-04-11T13:38:02.583Z","avatar_url":"https://github.com/teunbrand.png","language":"R","funding_links":[],"categories":["R"],"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  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# ggchromatic \u003cimg src='man/figures/logo.png' align=\"right\" height=\"138\" /\u003e\n\n*/ʤiː-ʤiːkrəʊˈmætɪk/*\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)\n[![R-CMD-check](https://github.com/teunbrand/ggchromatic/workflows/R-CMD-check/badge.svg)](https://github.com/teunbrand/ggchromatic/actions)\n[![Codecov test coverage](https://codecov.io/gh/teunbrand/ggchromatic/branch/master/graph/badge.svg)](https://codecov.io/gh/teunbrand/ggchromatic?branch=master)\n\u003c!-- badges: end --\u003e\n\nThe 'ggchromatic' package provides additional colour and fill scales to use with 'ggplot2' It uses the 'ggplot2' extension system to map a number of variables to different colour spaces with the 'farver' package. The package introduces 'chromatic scales', a term mirroring music terms. In music, chromatic scales cover all 12 notes. In ggchromatic, a chromatic scale can cover all channels in colour space. Admittedly, colour spaces might not be the most intuitive tool for interpreting a data visualisation, but can be useful for visualising less strict data impressions.\n\n## Installation\n\nYou can install the development of ggchromatic version from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"teunbrand/ggchromatic\")\n```\n## Example\n\nThese is a basic example of mapping three variables to the RGB colour space. This happens automatically for colours constructed by `rgb_spec()`.\n\n```{r}\nlibrary(ggchromatic)\n\nggplot(mtcars, aes(mpg, disp)) +\n  geom_point(aes(colour = cmy_spec(mpg, drat, wt)))\n```\n\nThe associated scale functions give more options for customisation, like the HSV scale below.\n\n```{r}\ndf \u003c- data.frame(\n  x = c(row(volcano)), y = c(col(volcano)), z = c(volcano)\n)\n\nggplot(df, aes(x, y, fill = hsv_spec(z, x, y))) +\n  geom_raster() +\n  scale_fill_hsv(limits = list(h = c(NA, 170)),\n                 oob = scales::oob_squish,\n                 channel_limits = list(h = c(0, 0.8))) +\n  coord_equal()\n```\n\nPerhaps a use-case for chromatic scales is when the interpretation of a variable isn't directly related to a property of the data points. For example, embeddings project data into a new space which might preserve some properties, such as distance between data points, but wherein dimensions of the new space are meaningless on their own. You can use a chromatic scale to map the embedding to colours, which can give a neat 'flavour' to the data points through colour.\n\n```{r}\nif (requireNamespace(\"umap\")) {\n  set.seed(42)\n\n  # Project the iris dataset into 3D UMAP space\n  config \u003c- umap::umap.defaults\n  config$n_components \u003c- 3\n  umap_3d \u003c- umap::umap(iris[, 1:4], config)$layout\n  \n  df \u003c- data.frame(\n    SL = iris$Sepal.Length,\n    SW = iris$Petal.Width,\n    x = umap_3d[, 1],\n    y = umap_3d[, 2],\n    z = umap_3d[, 3]\n  )\n  \n  ggplot(df, aes(SL, SW)) +\n    geom_point(aes(colour = rgb_spec(x, y, z)))\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteunbrand%2Fggchromatic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteunbrand%2Fggchromatic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteunbrand%2Fggchromatic/lists"}