{"id":16896161,"url":"https://github.com/teunbrand/legendry","last_synced_at":"2025-05-16T01:04:33.123Z","repository":{"id":57594545,"uuid":"492553988","full_name":"teunbrand/legendry","owner":"teunbrand","description":"A 'ggplot2' extension that focusses on expanding the plotter's arsenal of guides, such as axes, legends and colour bars. It brings     various improvements to existing guides by re-implementation, as well as adding novel guides.","archived":false,"fork":false,"pushed_at":"2025-04-13T12:50:55.000Z","size":27445,"stargazers_count":241,"open_issues_count":6,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-14T17:49:18.989Z","etag":null,"topics":["axis","axis-customization","ggplot-extension","ggplot2","legend","r","r-package","visualization"],"latest_commit_sha":null,"homepage":"https://teunbrand.github.io/legendry/","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":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null}},"created_at":"2022-05-15T17:18:07.000Z","updated_at":"2025-05-03T07:16:37.000Z","dependencies_parsed_at":"2024-04-27T09:29:21.654Z","dependency_job_id":"7d9d27f1-860a-4f4d-a995-b9b0d46c9c2b","html_url":"https://github.com/teunbrand/legendry","commit_stats":null,"previous_names":["teunbrand/legendry","teunbrand/gguidance"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teunbrand%2Flegendry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teunbrand%2Flegendry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teunbrand%2Flegendry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teunbrand%2Flegendry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teunbrand","download_url":"https://codeload.github.com/teunbrand/legendry/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448579,"owners_count":22072764,"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":["axis","axis-customization","ggplot-extension","ggplot2","legend","r","r-package","visualization"],"created_at":"2024-10-13T17:28:42.195Z","updated_at":"2025-05-16T01:04:33.086Z","avatar_url":"https://github.com/teunbrand.png","language":"R","funding_links":[],"categories":["Presentation, composition and scales"],"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}\n#| include: false\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"80%\",\n  dev = \"svglite\",\n  dev.args = list(fix_text_size = FALSE),\n  dpi = 132,\n  fig.align = \"center\"\n)\n```\n\n# legendry \u003ca href=\"https://teunbrand.github.io/legendry/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" alt=\"legendry website\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/teunbrand/legendry/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/teunbrand/legendry/actions/workflows/R-CMD-check.yaml)\n[![CRAN status](https://www.r-pkg.org/badges/version/legendry)](https://www.r-pkg.org/badges/version/legendry)\n[![Codecov test coverage](https://codecov.io/gh/teunbrand/legendry/graph/badge.svg)](https://app.codecov.io/gh/teunbrand/legendry)\n\u003c!-- badges: end --\u003e\n\nThe goal of legendry is to provide additional guide functionality to the ggplot2 ecosystem.\n\n## Installation\n\nYou can install the development version of legendry from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"teunbrand/legendry\")\n```\n\n## Example\n\nLet's first set up a basic plot to experiment with:\n\n```{r}\n#| label: basic_plot\nlibrary(legendry)\n\nbase \u003c- ggplot(mpg, aes(displ, hwy, colour = cty)) +\n  geom_point() +\n  labs(\n    x = \"Engine displacement\",\n    y = \"Highway miles per gallon\",\n    col = \"City miles\\nper gallon\"\n  ) +\n  theme(axis.line = element_line())\n```\n\nThe legendry package offers a selection of what it calls 'complete guides'. \nThese complete guides can just be drop-in replacement of regular guides, which you can specify using ggplot2's `guides()` function or using the `guide` argument in scales.\nIn the example below, we're using two custom variants of vanilla guides, namely `guide_axis_base()` and `guide_colbar()`. These custom variants have additional options that allow a greater degree of customisation: \n\n* The axis guide has an option for bidirectional ticks.\n* The colourbar automatically recognises out-of-bounds values and displays this with a cap.\n\n```{r}\n#| label: full_guides\nbase + \n  scale_colour_viridis_c(\n    limits = c(NA, 30),\n    guide = \"colbar\"\n  ) +\n  guides(\n    x = guide_axis_base(bidi = TRUE)\n  )\n```\n\nBesides complete guides, legendry also has incomplete guides that can be composed.\nThe `ggplot2::guide_axis_stack()` is an axis composition function that can be used to display multiple guides.\nHere, we use a 'primitive' guide (incomplete building block) to display a range on the axis.\nBy stacking it with a regular axis the primitive guide is completed.\n\n```{r}\n#| label: primitives\n# A partial guide to display a bracket\nefficient_bracket \u003c- primitive_bracket(\n  # Keys determine what is displayed\n  key = key_range_manual(start = 25, end = Inf, name = \"Efficient\"),\n  bracket = \"square\",\n  # We want vertical text\n  theme = theme(\n    legend.text = element_text(angle = 90, hjust = 0.5),\n    axis.text.y.left = element_text(angle = 90, hjust = 0.5)\n  )\n)\n\nbase + guides(y = guide_axis_stack(\"axis\", efficient_bracket))\n```\n\nThe legendry package extends this guide composition concept beyond the axes for other types of guides.\nIn the example below we compose a 'sandwich': a central guide flanked by two others.\nBecause our bracket is a primitive, it does not matter what aesthetic it displays and we can re-use it for the sandwich.\nI've yet to write the vignette on composition.\n\n```{r}\n#| label: composition\nbase + \n  scale_colour_viridis_c(\n    guide = compose_sandwich(\n      middle = gizmo_density(), \n      text = \"axis_base\",\n      opposite = efficient_bracket\n    )\n  )\n```\n\n## Code of Conduct\n\nPlease note that the legendry project is released with a [Contributor Code of Conduct](https://teunbrand.github.io/legendry/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteunbrand%2Flegendry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteunbrand%2Flegendry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteunbrand%2Flegendry/lists"}