{"id":13711536,"url":"https://dgkf.github.io/ggpackets/","last_synced_at":"2025-05-06T21:31:39.586Z","repository":{"id":40209114,"uuid":"117747793","full_name":"dgkf/ggpackets","owner":"dgkf","description":"Cleaner composition of ggplot layers","archived":false,"fork":false,"pushed_at":"2025-03-03T01:04:40.000Z","size":16577,"stargazers_count":69,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-05T21:09:59.713Z","etag":null,"topics":["ggplot","plotting","r"],"latest_commit_sha":null,"homepage":"https://dgkf.github.io/ggpackets","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/dgkf.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}},"created_at":"2018-01-16T22:01:47.000Z","updated_at":"2025-03-03T01:02:51.000Z","dependencies_parsed_at":"2022-06-27T00:02:45.270Z","dependency_job_id":null,"html_url":"https://github.com/dgkf/ggpackets","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkf%2Fggpackets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkf%2Fggpackets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkf%2Fggpackets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkf%2Fggpackets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgkf","download_url":"https://codeload.github.com/dgkf/ggpackets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252772028,"owners_count":21801832,"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":["ggplot","plotting","r"],"created_at":"2024-08-02T23:01:09.171Z","updated_at":"2025-05-06T21:31:39.567Z","avatar_url":"https://github.com/dgkf.png","language":"R","funding_links":[],"categories":["Plot layers"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n# ggpackets \u003cimg src=\"man/figures/ggpackets-hex-small.png\" align=\"right\" width=\"134px\"/\u003e\n\n[![CRAN](https://img.shields.io/cran/v/ggpackets.svg)](https://cran.r-project.org/package=ggpackets)\n[![downloads](https://cranlogs.r-pkg.org/badges/ggpackets)](https://cran.r-project.org/package=ggpackets)\n[![R-CMD-check](https://github.com/dgkf/ggpackets/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dgkf/ggpackets/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/dgkf/ggpackets/graph/badge.svg)](https://app.codecov.io/gh/dgkf/ggpackets)\n\n## Overview\n\nTake a look at the **[ggpackets project page](https://dgkf.github.io/ggpackets/)**!\n\nEasily build components of ggplots without sacrificing the ease of ggplot's\nlayer parameters and construction syntax. \n\n### Installation\n\n```{r, eval = FALSE}\ninstall.packages(\"ggpackets\")\n```\n\n_or install the development version_\n\n```{r, eval = FALSE}\ndevtools::install_github(\"dgkf/ggpackets\", build_vignettes = TRUE)\n```\n\n## Get Involved\n\nThere are plenty of ways to help contribute:\n\n1. **File issues!**  \n   Found a bug? Think the syntax looks ugly? Don't like the name? Tell me!\n   [Issues](https://github.com/dgkf/ggpackets/issues) are the best way to start\n   the conversation.\n\n2. **Write documentation!**  \n   More resources always helps. Found a function unintuitive? Example code and\n   improved function descriptors would be helpful. If you use the package and\n   would feel comfortable writing about a topic not yet covered in a vignette,\n   feel free to contribute a new vignette for it.\n\n3. **Write Unit Tests!**  \n   There's some pretty sophisticated manipulations going on under the hood to\n   make everything as clean as possible, because of that it's important to make\n   sure everything stays working the way we expect it to. Unit test\n   contributions always welcome!\n   \n4. **Contribute Code!**  \n   Last but not least, code contributors are welcome. Reach out and get in\n   touch if you're passionate about the goal of the project. \n\n## Quick Start\n\nDefine common ggplot layer sets together into a singled object. Connect all\nyour plots with a single plot component definition and debug one central\nlocation. Build beautiful templates and save them once, reuse them easily and\nwithout having to abandon the ggplot construction framework.\n\n```{r, include=FALSE}\nknitr::opts_chunk$set(\n  echo = TRUE,\n  fig.align = \"center\",\n  fig.width = 6,\n  fig.height = 4,\n  out.width = \"600px\",\n  out.height = \"400px\"\n)\n\nlibrary(ggplot2)\nlibrary(ggpackets)\n```\n\n```{r}\nggpk_box_and_scatter \u003c- ggpacket() +\n  geom_point(position = position_jitter(width = 0.4), alpha = 0.02) +\n  geom_boxplot(outlier.shape = NA, fill = NA, color = \"black\") +\n  geom_text(\n    stat = \"summary\",\n    vjust = -1,\n    fun.data = function(d) {\n      c(y = quantile(d, 0.75, names = FALSE) + 1.5 * IQR(d), label = length(d))\n    }\n  ) +\n  theme_linedraw() +\n  scale_color_distiller(palette = \"Set1\")\n```\n\nNow we can use that template repeatedly with a much simpler ggplot call\n\n```{r diamonds.boxplot, eval = FALSE}\nggplot(diamonds, aes(x = cut, y = price, color = carat)) +\n  ggpk_box_and_scatter() +\n  ggtitle(\"Diamond price distribution by cut\")\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/18220321/98409555-f0298b80-2027-11eb-83f9-b2d208e1c037.png\" width=\"600px\" height=\"400px\" style=\"display: block; margin: auto;\" /\u003e\n\n## Handle custom arguments \u0026 parameter propegation\n\nIn addition to simply wrapping multiple `ggplot2` layers, `ggpackets` can\nstreamline a number of complicated plotting scenarios such as passing arguments\nto sets of layers, setting default argument values with scoped overrides,\nrouting aesthetic mappings to be reused within specific layers for other\naesthetics and scoping data usage over a set of layers.\n\n```{r}\nggpk_labelled_heatmap \u003c- function(...) {\n  ggpacket(...) %+%\n    geom_tile(.id = \"tile\", color = NA, ...) %+%\n    geom_text(\n      .id = c(\"text\", \"text1\"),\n      color = \"black\",\n      vjust = -0.3,\n      fontface = \"bold\",\n      ...\n    ) %+%\n    geom_text(\n      .id = c(\"text\", \"text2\"),\n      aes(label = sprintf(\"(%.1f)\", ..fill..)),\n      color = \"black\",\n      vjust = 1.1,\n      ...\n    ) %+%\n    theme_void()\n}\n```\n\nIn this function we make use of a number of these specialized behaviors.\n\n1. `.id` parameters are set to tag specific layers with an identifier, which\n   can be used to prefix arguments to route them to a subset of the `ggpacket`\n   layers. Multiple IDs can be used, and arguments will filter down into that\n   layer if they match any of the provided IDs. \n1. Ellipsis are first passed to `ggpacket(...)`, which will pass them on as\n   default values to all `ggpacket` layers.\n1. Ellipsis are also passed at the tail end of each layer call, allowing\n   arguments to mask default values. The placement of the ellipsis determines\n   whether arguments will override or be overridden by the existing parameters.\n   After expanding the ellipsis, the last instance of each argument is used to\n   build the call.\n1. Aesthetics are rerouted using the specialized `..\u003caesthetic\u003e..` syntax.\n1. We use `%+%` instead of the commonly-used `+` to add layers together, which\n   allows `ggpackets` to accept non-standard arguments before ggplot sends us\n   warnings about them.\n\n```{r orchid.heatmap, eval = FALSE}\nggplot(as.data.frame(OrchardSprays)) +\n  aes(x = rowpos, y = colpos, label = treatment, fill = decrease) +\n  ggpk_labelled_heatmap(text.color = \"white\", text2.alpha = 0.5) +\n  ggtitle(\"Honeybee population decline in repellent trial grid\")\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/18220321/98409633-12230e00-2028-11eb-87c9-163156f03514.png\" width=\"600px\" height=\"400px\" style=\"display: block; margin: auto;\" /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/dgkf.github.io%2Fggpackets%2F","html_url":"https://awesome.ecosyste.ms/projects/dgkf.github.io%2Fggpackets%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/dgkf.github.io%2Fggpackets%2F/lists"}