{"id":32176316,"url":"https://github.com/iamamutt/ggdistribute","last_synced_at":"2026-02-18T21:02:55.709Z","repository":{"id":53485546,"uuid":"132702929","full_name":"iamamutt/ggdistribute","owner":"iamamutt","description":"ggplot2 extension for plotting distributions","archived":false,"fork":false,"pushed_at":"2021-03-29T06:38:59.000Z","size":4622,"stargazers_count":17,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-21T19:57:32.047Z","etag":null,"topics":["bayesian-inference","ggplot-extension","ggplot2","ggplot2-theme","plotting","r"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamamutt.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-05-09T04:47:08.000Z","updated_at":"2021-02-10T04:46:10.000Z","dependencies_parsed_at":"2022-08-18T20:20:27.903Z","dependency_job_id":null,"html_url":"https://github.com/iamamutt/ggdistribute","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iamamutt/ggdistribute","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamamutt%2Fggdistribute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamamutt%2Fggdistribute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamamutt%2Fggdistribute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamamutt%2Fggdistribute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamamutt","download_url":"https://codeload.github.com/iamamutt/ggdistribute/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamamutt%2Fggdistribute/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29596125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T20:59:56.587Z","status":"ssl_error","status_checked_at":"2026-02-18T20:58:41.434Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["bayesian-inference","ggplot-extension","ggplot2","ggplot2-theme","plotting","r"],"created_at":"2025-10-21T19:57:32.180Z","updated_at":"2026-02-18T21:02:55.703Z","avatar_url":"https://github.com/iamamutt.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 the .Rmd file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse=TRUE,\n  comment=\"#\u003e\",\n  strip.white=FALSE,\n  tidy=FALSE,\n  dpi=300,\n  fig.align=\"center\",\n  fig.path=\"man/figures/README-\",\n  fig.width=5.25,\n  fig.height=3.8,\n  out.width=\"700px\"\n)\n```\n\n\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/ggdistribute)](https://cran.r-project.org/package=ggdistribute)\n\n# ggdistribute\n\nA `ggplot2` Extension for Plotting Unimodal Distributions\n\nThe `ggdistribute` package is an extension for plotting posterior or other types of unimodal distributions that require overlaying information about a distribution's intervals. It makes use of the `ggproto` system to extend `ggplot2`, providing additional \"geoms\", \"stats\", and \"positions.\" The extensions integrate with existing `ggplot2` layer elements.\n\n## Example\n\n```{r, echo=FALSE, message=FALSE, results='hide', warning=FALSE}\nlibrary(ggplot2)\ndevtools::load_all(\".\", export_all = FALSE)\ntheme_set(theme_mejr())\n```\n\nThe package function `example_plot()` is an overview of combining `ggdistribute` with other `ggplot2` elements. The contents of this function are printed below and gives details about the extended parts to `ggplot2`.\n\n```{r, eval=FALSE}\nlibrary(ggplot2)\nlibrary(ggdistribute)\n```\n\n```{r turtle_snails, echo = FALSE, fig.width=5, fig.height=3, out.width=\"100%\"}\nplot(example_plot())\n```\n\n```{r prin_ex_plot, echo=FALSE, results='asis'}\nggdistribute:::function2chunk(\"example_plot\")\n```\n\n## Additional examples from an arbritrary dataset\n\n```{r}\n# total number of samples in the dataset\nN \u003c- 2500\nmeans \u003c- c(-1, 2, 3, 5)\n```\n\nThe `data` object below is a randomly generated dataset of `r length(means)` different normal distributions. Two factors, `Condition` and `Group`, are assigned to subsets of the generated values. `r N` samples are generated for each value of `mu` for a total of $ `r N*length(means)` $ rows.\n\n```{r norm_data}\ndata \u003c- data_normal_sample(mu = means, n = N)\n```\n\nCreate a new grouping variable called `Level` based on the column `Group`.\n\n```{r norm_data_grps}\n# number of levels to make\nnum_levels \u003c- 8L\n\n# R version \u003e= 3.5 now let's you assign factors this way.\ndata$Level \u003c- with(data, factor(\n  Group,\n  levels = letters[seq_len(num_levels)],\n  labels = c(rep(\"Low\", 3), rep(\"Mid\", 2), rep(\"High\", 3)),\n  ordered = TRUE\n))\n```\n\nShow unique groups per `Group`, `Condition`, and `Level` to help understand the data factors.\n\n```{r}\nunique(data[, c(\"Group\", \"Condition\", \"Level\")])\n```\n\n### Facetting and spreading groups\n\n```{r space_ships, fig.width=5, fig.height=4}\nggplot(data) +\n  aes(x=value, y=Condition, group=Group) +\n  geom_posterior(\n    aes(fill=Level),\n    mirror=TRUE,\n    show.legend=FALSE,\n    adjust=1.5,\n    brighten=c(6, 0, 2.5),\n    position=position_spread(reverse=TRUE)\n  ) +\n  geom_point(\n    aes(color=Level, shape=Condition),\n    alpha=.08,\n    fill=NA,\n    show.legend=FALSE,\n    position=position_jitter(0, .45)\n  ) +\n  coord_cartesian(ylim=c(0.5, 2.5), expand=FALSE) +\n  facet_wrap(~ Level, scales=\"free\") +\n  labs(title=\"Space Invaders\", y=\"Condition\", x=\"Parameter estimate\")\n```\n\n### Changing the appearance of `geom_posterior`\n\n```{r candy_wrappers, fig.width=5, fig.height=4}\nggplot(data) +\n  aes(x=value, y=Group) +\n  geom_vline(\n    xintercept=0, size=.6\n  ) +\n  geom_posterior(\n    aes(color=Condition),\n    midline=NULL,\n    mirror=TRUE,\n    fill=\"#FFFFFF\",\n    draw_sd=FALSE,\n    interval_type=\"hdi\",\n    vjust=0,\n    position=position_spread(height=2)\n  ) +\n  labs(\n    title=\"Candy Wrappers\",\n    x=\"Parameter estimate\",\n    y=\"Sample location\"\n  ) +\n  scale_x_continuous(breaks=seq(-10, 10, 1)) +\n  theme(\n    legend.position=c(.025, .9),\n    legend.justification=c(0, 0),\n    panel.grid.major.y=element_line(color=gray(.92))\n  )\n```\n\n### The *y* axis is a repeated, continuous grouping variable\n\nThe variable `GroupScore` is a continuous variable assigned to each `Group`. The distributions will be positioned at the start of the y value for each group, and resized to not overlap with the next group. Resizing can be overriden by specifying `height` in `position_spread`.\n\n```{r y_cont}\nunique(data[, c(\"Group\", \"GroupScore\")])\n```\n\n```{r rainbow_hills, fig.width=5, fig.height=6}\nggplot(data) +\n  aes(x=value, y=GroupScore) +\n  geom_vline(\n    xintercept=0, size=.6\n  ) +\n  geom_posterior(\n    aes(fill=Group),\n    midline=\"#FFFFFF\",\n    colour=\"#FFFFFF\",\n    alpha=0.7,\n    brighten=c(1.3, 0, -1.3),\n    interval_type=\"hdi\",\n    position=position_spread(height=0.5, padding=0)\n  ) +\n  labs(\n    title=\"Rainbow Hills\",\n    x=\"Parameter estimate\",\n    y=\"Group's score\"\n  ) +\n  scale_x_continuous(breaks=seq(-10, 10, 1)) +\n  scale_y_continuous(breaks=seq(-10, 10, .5))\n```\n\n## How to install\n\n### Dependencies\n\n- R: \u003chttps://www.r-project.org/\u003e\n\nA current R installation.\n\n#### Dependencies for installing the development version of this package\n\n- `devtools` package: \u003chttps://www.rstudio.com/products/rpackages/devtools/\u003e\n\nThe `devtools` package is an R package that makes it easier to install local or remote content as an R package that can be used like any other standard R package. You can install `devtools` by opening up RStudio or an R terminal and running\n\n```{r devtools-inst, eval=FALSE}\ninstall.packages(\"devtools\")\n```\n\nFor Windows users, you *may* be required to install Rtools first before you can use the `devtools` package, if there is any code that needs to be compiled. These are a set of build tools customized for building R packages (see the `devtools` link above for more details).\n\n- Build tools: \u003chttp://cran.r-project.org/bin/windows/Rtools/\u003e\n\n### Installing from CRAN\n\n\nIf you want to use the last version that was uploaded to the CRAN repository, do the following:\n\n```{r cran-inst, eval=FALSE}\ninstall.packages(\"ggdistribute\")\n```\n\n### Installing from the downloaded package content folder\n\nIf you have all of the `ggdistribute` package contents (e.g., an unzipped folder containing `DESCRIPTION`, `NAMESPACE`, `R/`, etc...), you can open up the `ggdistribute.Rproj` file in RStudio and use both `devtools` and RStudio to load or install package.\n\nThe first step is to make sure you have all the package dependencies (other packages that this pacakge relies on) to be able to load or install the `ggdistribute` package materials. You can run the line below to install dependencies first.\n\n```{r local-inst-dep, eval=FALSE}\ndevtools::install_dev_deps()\n```\n\nAfter the dependencies are installed, you can now build and install `ggdistribute` from the current working directory.\nAssuming the `ggdistribute` project is loaded in RStudio, you can leave out the first argument.\n\n```{r local-inst, eval=FALSE}\ndevtools::install()\n```\n\nIf installing from a different working directory, enter the path of the package contents to manually specify what to install.\n\n```{r local-inst-alt, eval=FALSE}\ndevtools::install_dev_deps(\"/Path/to/the/folder/ggdistribute\")\ndevtools::install(\"/Path/to/the/folder/ggdistribute\")\n```\n\n\n### Installing from GitHub\n\nIf `devtools` are installed, you may use the `install_github()` function to download and install the development version of the package from this GitHub repository instead of the one hosted on CRAN. Run the code below to download and install the development version:\n\n```{r gh-installation, eval = FALSE}\ndevtools::install_github(\"iamamutt/ggdistribute\")\n```\n\nor to install all suggested packages as well...\n\n```{r gh-installation-dep, eval = FALSE}\ndevtools::install_github(\"iamamutt/ggdistribute\", dependencies=TRUE)\n```\n\n### Loading the package\n\nIf successful, the package should now be installed and can be loaded as any other package. Repeat the last intall step if there are updates to the package, or complete all steps to install on another machine. You should now be able to use the package materials and should see it in your packages tab if using RStudio. It should be loaded like any other package.\n\n```{r load-pkg, eval=FALSE}\nlibrary(ggdistribute)\n```\n\n\n## Getting help\n\n### Browsing the vignettes\n\nVignettes can be viewed in several different ways.\n\n- pre-built and saved in the `inst\\doc` folder on GitHub.\n- calling `vignette(\"geom_posterior\", \"ggdistribute\")` from within R after the package is installed.\n- navigating to packages tab \u003e ggdistribute \u003e User guides, package vignettes... in RStudio.\n\n### Viewing the help documentation\n\nView the package welcome page to navigate to different types of help documents\n\n```{r show-welcome, eval=FALSE}\npackage?ggdistribute\n```\n\nViewing package information and a list of exported objects:\n\n```{r show-help, eval=FALSE}\nhelp(package = \"ggdistribute\")\n\n# or\nlibrary(help=\"ggdistribute\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamamutt%2Fggdistribute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamamutt%2Fggdistribute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamamutt%2Fggdistribute/lists"}