{"id":13711118,"url":"https://github.com/doehm/ggbrick","last_synced_at":"2025-10-30T19:52:53.044Z","repository":{"id":176646718,"uuid":"659205930","full_name":"doehm/ggbrick","owner":"doehm","description":"A brick like geom for ggplot2","archived":false,"fork":false,"pushed_at":"2025-09-15T00:35:34.000Z","size":8278,"stargazers_count":48,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-15T02:37:42.368Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/doehm.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-06-27T10:48:14.000Z","updated_at":"2025-09-15T00:35:38.000Z","dependencies_parsed_at":"2024-08-03T00:14:05.297Z","dependency_job_id":null,"html_url":"https://github.com/doehm/ggbrick","commit_stats":null,"previous_names":["doehm/ggbrick"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/doehm/ggbrick","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doehm%2Fggbrick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doehm%2Fggbrick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doehm%2Fggbrick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doehm%2Fggbrick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doehm","download_url":"https://codeload.github.com/doehm/ggbrick/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doehm%2Fggbrick/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281873520,"owners_count":26576262,"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","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-08-02T23:01:04.678Z","updated_at":"2025-10-30T19:52:53.009Z","avatar_url":"https://github.com/doehm.png","language":"R","funding_links":[],"categories":["Plot layers"],"sub_categories":[],"readme":"---\noutput: \n  github_document\n---\n\n```{r, echo=FALSE}\nsuppressPackageStartupMessages(library(dplyr))\nknitr::opts_chunk$set(fig.width=14)\n```\n\n\u003cimg src='https://cranlogs.r-pkg.org/badges/ggbrick'/\u003e\u003cimg src='https://cranlogs.r-pkg.org/badges/grand-total/ggbrick'/\u003e\u003cimg src='https://www.r-pkg.org/badges/version/ggbrick'/\u003e\n\n# ggbrick \u003cimg src='dev/images/ggbrick1.png' align=\"right\" height=\"240\" /\u003e\n\nIf you’re looking for something a little different, `ggbrick` creates a ‘waffle’ style chart with the aesthetic of a brick wall. The usage is similar to `geom_col` where you supply counts as the height of the bar and a fill for a stacked bar. Each whole brick represents 1 unit. Two half bricks equal one whole brick.\n\n# Installation\n\nInstall from CRAN\n\n```{r, eval=FALSE}\ninstall.packages(\"ggbrick\")\n```\n\nor from Git\n\n```{r, eval=FALSE}\ndevtools::install_github(\"doehm/ggbrick\")\n```\n\n# Geoms\n\nThere are two main geoms included:\n\n1. `geom_brick()`: To make the brick wall-style waffle chart.\n2. `geom_waffle()`: To make a regular-style waffle chart.\n\n## geom_brick()\n\nUse `geom_brick()` the same way you would use `geom_col()`.\n\n```{r}\nlibrary(dplyr)\nlibrary(ggplot2)\nlibrary(ggbrick)\n \n# basic usage\nmpg |\u003e\n  count(class, drv) |\u003e\n  ggplot() +\n  geom_brick(aes(class, n, fill = drv)) +\n  coord_brick()\n```\n\n`coord_brick()` is included to maintain the aspect ratio of the bricks. It is similar to `coord_fixed()`, in fact, it is just a wrapper for `coord_fixed()` with a parameterised aspect ratio based on the number of bricks. The default number of bricks is 4. To change the width of the line outlining the brick use the linewidth parameter as normal.\n\nTo change specify the `bricks_per_layer` parameter in the geom and coord functions.\n\n```{r}\nmpg |\u003e\n  count(class, drv) |\u003e\n  ggplot() +\n  geom_brick(aes(class, n, fill = drv), bricks_per_layer = 6) +\n  coord_brick(6)\n```\n\nYou can change the width of the columns similar to `geom_col()` to add more space between the bars. To maintain the aspect ratio you also need to set the width in `coord_brick()`.\n\n```{r}\nmpg |\u003e\n  count(class, drv) |\u003e\n  ggplot() +\n  geom_brick(aes(class, n, fill = drv), width = 0.5) +\n  coord_brick(width = 0.5)\n```\n\nTo get more space between each brick use the `gap` parameter.\n\n```{r}\nmpg |\u003e\n  count(class, drv) |\u003e\n  ggplot() +\n  geom_brick(aes(class, n, fill = drv), gap = 0.04) +\n  coord_brick()\n```\n\nFor no gap set `gap = 0` or use the shorthand `geom_brick0()`.\n\n```{r}\nmpg |\u003e\n  count(class, drv) |\u003e\n  ggplot() +\n  geom_brick0(aes(class, n, fill = drv)) +\n  coord_brick()\n```\n\nFor fun, I’ve included a parameter to randomise the fill of the bricks or add a small amount of variation at the join between two groups. The proportions are maintained and designed to just give a different visual.\n\n```{r}\nmpg |\u003e\n  count(class, drv) |\u003e\n  ggplot() +\n  geom_brick(aes(class, n, fill = drv), type = \"soft_random\") +\n  coord_brick()\n```\n\n```{r}\nmpg |\u003e\n  count(class, drv) |\u003e\n  ggplot() +\n  geom_brick(aes(class, n, fill = drv), type = \"random\") +\n  coord_brick()\n```\n\n## geom_waffle()\n\n`geom_waffle()` has the same functionality as `geom_brick()` but the bricks are square giving a standard waffle chart. I added this so you can make a normal waffle chart in the same way you would use `geom_col()`. It requires `coord_waffle()`. To maintain the aspect ratio.\n\n```{r}\nmpg |\u003e\n  count(class, drv) |\u003e\n  ggplot() +\n  geom_waffle(aes(class, n, fill = drv)) +\n  coord_waffle()\n```\n\n```{r}\nmpg |\u003e\n  count(class, drv) |\u003e\n  ggplot() +\n  geom_waffle0(aes(class, n, fill = drv), bricks_per_layer = 6) +\n  coord_waffle(6)\n```\n\nYou may want to flip the coords when using `geom_waffle()`. To do so you’ll need to use `coord_flip()` and `theme(aspect.ratio = \u003cnumber\u003e)`. \n\n```{r, fig.width=5, fig.height=7.5}\nmpg |\u003e\n  count(class, drv) |\u003e\n  ggplot() +\n  geom_waffle0(aes(class, n, fill = drv)) +\n  coord_flip() +\n  theme(aspect.ratio = 1.8)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoehm%2Fggbrick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoehm%2Fggbrick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoehm%2Fggbrick/lists"}