Science Score: 49.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 11 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.7%) to scientific vocabulary
Keywords
ggplot2
r
r-package
uncertainty
uncertainty-visualization
visualization
Keywords from Contributors
visualisation
shiny
standardization
tidy-data
report
Last synced: 6 months ago
·
JSON representation
Repository
Visualizations of distributions and uncertainty
Basic Info
- Host: GitHub
- Owner: mjskay
- License: gpl-3.0
- Language: R
- Default Branch: master
- Homepage: https://mjskay.github.io/ggdist/
- Size: 256 MB
Statistics
- Stars: 863
- Watchers: 9
- Forks: 30
- Open Issues: 62
- Releases: 17
Topics
ggplot2
r
r-package
uncertainty
uncertainty-visualization
visualization
Created over 5 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
---
```{r chunk_options, include=FALSE}
knitr::opts_chunk$set(
fig.path = "man/figures/README/"
)
knitr::opts_chunk$set(
fig.retina = 2
)
if (requireNamespace("ragg", quietly = TRUE)) {
knitr::opts_chunk$set(
dev = "ragg_png"
)
} else if (capabilities("cairo")) {
knitr::opts_chunk$set(
dev = "png",
dev.args = list(png = list(type = "cairo"))
)
}
```
# ggdist: Visualizations of distributions and uncertainty
[](https://github.com/mjskay/ggdist/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/github/mjskay/ggdist?branch=master)
[](https://cran.r-project.org/package=ggdist)

[](https://doi.org/10.1109/TVCG.2023.3327195)
[](https://doi.org/10.5281/zenodo.3879620)
```{r setup, include=FALSE}
library(dplyr)
library(tidyr)
library(distributional)
library(ggdist)
library(ggplot2)
library(patchwork)
theme_set(theme_ggdist())
```
```{r preview_setup, include=FALSE}
set.seed(12345)
d = dist_normal(4, 1)
d_quantiles = dist_sample(list(qnorm(ppoints(1000), 4, 1)))
q_100 = qnorm(ppoints(100), 4, 1)
x_samples_100 = rnorm(100, 4, 1)
d_samples_100 = dist_sample(list(x_samples_100))
dists_xlim = c(0,8)
```
```{r preview_slabinterval, include=FALSE}
slabinterval_plot = ggplot() +
stat_halfeye(aes(y = "01", xdist = d)) +
stat_eye(aes(y = "02", xdist = d)) +
stat_gradientinterval(aes(y = "03", xdist = d), scale = 0.75, fill_type = "gradient", show_interval = FALSE, show_point = FALSE, position = position_nudge(y = -0.2)) +
stat_ccdfinterval(aes(y = "04", xdist = d), scale = .5, justification = 0, position = position_nudge(y = -0.3)) +
stat_cdfinterval(aes(y = "05", xdist = d), scale = .5, justification = 0, position = position_nudge(y = -0.2)) +
stat_interval(
aes(y = "06", xdist = d), color = "gray65", alpha = 1/3, linewidth = 10,
position = position_nudge(y = -.1)
) +
stat_pointinterval(aes(y = "07", xdist = d)) +
stat_slab(aes(y = "08", xdist = d), position = position_nudge(y = - 0.2)) +
stat_histinterval(aes(y = "09", xdist = d_quantiles), position = position_nudge(y = - 0.25)) +
stat_slab(
aes(y = "10", xdist = d, fill_ramp = after_stat(level)),
show.legend = FALSE, .width = c(.5, .8, .95),
fill = scales::brewer_pal()(7)[[5]],
position = position_nudge(y = -0.5)
) +
stat_spike(
aes(y = "10", xdist = d, linetype = after_stat(at)),
at = c(mode = Mode, qi = function(...) qi(..., .width = .8)),
show.legend = FALSE,
position = position_nudge(y = -0.5)
) +
scale_x_continuous(limits = dists_xlim, expand = c(0,0), labels = NULL) +
scale_y_discrete(limits = rev, labels = NULL) +
labs(
title = "slabinterval",
x = NULL,
y = NULL
) +
theme(plot.margin = margin(5.5, 5.5, 5.5, 0), axis.ticks = element_blank())
```
```{r preview_dotsinterval, include=FALSE}
set.seed(123456)
x1 = rnorm(125, 3, 0.75)
x2 = rnorm(125, 5, 0.75)
dotsinterval_plot = ggplot() +
stat_dotsinterval(aes(y = "01", xdist = d)) +
stat_dots(aes(y = "02", xdist = d), layout = "weave", position = position_nudge(y = -0.2)) +
geom_weave(aes(y = "03", x = x1, fill = x1 > 4, group = NA), linewidth = NA, alpha = 0.75, binwidth = NA) +
geom_swarm(aes(y = "04", x = x2, fill = x2 > 4, group = NA), linewidth = NA, alpha = 0.75, binwidth = NA, position = position_nudge(y = 0.1)) +
scale_fill_brewer(palette = "Dark2", guide = "none") +
ggnewscale::new_scale_fill() +
stat_dotsinterval(aes(y = "05", xdist = d, fill = after_stat(level)), layout = "weave", slab_linewidth = NA, .width = c(.66, .95), quantiles = 200, position = position_nudge(y = -0.3)) +
scale_color_manual(values = scales::brewer_pal()(3)[-1], aesthetics = "fill", guide = "none") +
ggnewscale::new_scale_fill() +
geom_dots(aes(y = "06", x = x1, fill = "a"), side = "bottom", scale = 0.75, linewidth = NA, position = position_nudge(y = -0.1)) +
stat_slabinterval(aes(y = "06", x = x1, fill = "a"), scale = 0.5, position = position_nudge(y = -0.1)) +
geom_dots(aes(y = "07", x = x2, fill = "b"), side = "bottom", scale = 0.75, linewidth = NA, position = position_nudge(y = -0.2)) +
stat_slabinterval(aes(y = "07", x = x2, fill = "b"), scale = 0.5, position = position_nudge(y = -0.2)) +
scale_fill_brewer(palette = "Set2", guide = "none") +
scale_x_continuous(limits = dists_xlim, expand = c(0,0), labels = NULL) +
scale_y_discrete(limits = rev, labels = NULL) +
labs(
title = "dotsinterval",
x = NULL,
y = NULL
) +
theme(axis.ticks = element_blank())
```
```{r preview_lineribbon, include=FALSE}
m_mpg = lm(mpg ~ hp * cyl, data = mtcars)
mtcars_preds = mtcars %>%
group_by(cyl) %>%
expand(hp = seq(min(hp), max(hp), length.out = 50)) %>%
bind_cols(predict(m_mpg, newdata = ., se.fit = TRUE))
mtcars_plot = function(.width = c(.5, .8, .95), alpha = 1/4, ...) {
mtcars_preds %>%
ggplot(aes(x = hp, fill = ordered(cyl), color = ordered(cyl))) +
stat_lineribbon(
aes(ydist = dist_student_t(df, fit, se.fit)),
.width = .width, alpha = alpha, ...
) +
geom_point(aes(y = mpg), data = mtcars) +
scale_fill_brewer(palette = "Set2") +
scale_color_brewer(palette = "Dark2") +
labs(
color = "cyl",
fill = "cyl",
y = "mpg"
) +
theme_ggdist()
}
lineribbon_plot_1 = mtcars_plot() +
guides(color = "none", fill = "none", x = "none") +
scale_x_continuous(labels = NULL) +
scale_y_continuous(labels = NULL) +
labs(title = "lineribbon", x = NULL, y = NULL) +
theme(plot.margin = margin(5.5, 5.5, 0, 5.5), axis.ticks = element_blank())
lineribbon_plot_2 = mtcars_plot(.width = ppoints(30), alpha = 1/20) +
guides(color = "none", fill = "none") +
scale_x_continuous(labels = NULL) +
scale_y_continuous(labels = NULL) +
labs(x = NULL, y = NULL) +
theme(plot.margin = margin(0, 5.5, 5.5, 5.5), axis.ticks = element_blank())
```
```{r preview, echo=FALSE, fig.height=4.5, fig.width=9}
slabinterval_plot + dotsinterval_plot + (lineribbon_plot_1 / lineribbon_plot_2) +
plot_annotation(
caption = 'Some examples from the three main families of ggdist geometries'
)
```
[ggdist](https://mjskay.github.io/ggdist/) is an R package that provides a flexible set of `{ggplot2}` geoms and stats designed
especially for visualizing distributions and uncertainty. It is designed for both
frequentist and Bayesian uncertainty visualization, taking the view that uncertainty
visualization can be unified through the perspective of distribution visualization:
for frequentist models, one visualizes confidence distributions or bootstrap distributions (see `vignette("freq-uncertainty-vis")`);
for Bayesian models, one visualizes probability distributions (see the [tidybayes](https://mjskay.github.io/tidybayes/)
package, which builds on top of `{ggdist}`).
The `geom_slabinterval()` / `stat_slabinterval()` family (see `vignette("slabinterval")`) makes it
easy to visualize point summaries and intervals, eye plots, half-eye plots, ridge plots,
CCDF bar plots, gradient plots, histograms, and more:
The `geom_dotsinterval()` / `stat_dotsinterval()` family (see `vignette("dotsinterval")`) makes
it easy to visualize dot+interval plots, Wilkinson dotplots, beeswarm plots, and quantile dotplots
(and combined with half-eyes, composite plots like rain cloud plots):
```{r halfeye_dotplot, echo=FALSE, message=FALSE, warning=FALSE}
set.seed(12345) # for reproducibility
data.frame(
abc = c("a", "b", "c"),
value = rnorm(300, c(1, 8, 3), c(1, 1.7, 1))
) %>%
ggplot(aes(y = abc, x = value, fill = abc)) +
geom_dots(layout = "weave", side = "bottom", linewidth = 0) +
stat_slabinterval() +
scale_fill_brewer(palette = "Set2") +
theme_ggdist() +
labs(
title = "Rainclouds using geom_dots(layout = 'weave') with stat_slabinterval()"
)
```
The `geom_lineribbon()` / `stat_lineribbon()` family (see `vignette("lineribbon")`) makes it easy to visualize
fit lines with an arbitrary number of uncertainty bands:
```{r lineribbon, echo=FALSE, message=FALSE, warning=FALSE}
mtcars_plot()
```
All stats in `{ggdist}` also support visualizing analytical distributions and vectorized distribution
data types like [distributional](https://pkg.mitchelloharawild.com/distributional/) objects or `posterior::rvar()`
objects. This is particularly useful when visualizing uncertainty in frequentist
models (see `vignette("freq-uncertainty-vis")`) or when visualizing priors in a
Bayesian analysis.
The `{ggdist}` geoms and stats also form a core part of the [tidybayes](https://mjskay.github.io/tidybayes/) package (in fact,
they originally were part of `{tidybayes}`). For examples of the use of `{ggdist}` geoms and
stats for visualizing uncertainty in Bayesian models, see the vignettes in `{tidybayes}`, such as
`vignette("tidybayes", package = "tidybayes")` or `vignette("tidy-brms", package = "tidybayes")`.
## Cheat sheets
These cheat sheets focus on the `slabinterval` family of geometries:
## Installation
You can install the currently-released version from CRAN with this R
command:
```{r install, eval=FALSE}
install.packages("ggdist")
```
Alternatively, you can install the latest development version from GitHub with these R
commands:
```{r install_github, eval=FALSE}
install.packages("devtools")
devtools::install_github("mjskay/ggdist")
```
## Dependencies
`{ggdist}` aims to have minimal additional dependencies beyond those already
required by `{ggplot2}`. The `{ggdist}` dependencies fall into the following
categories:
1. `{ggplot2}`.
2. Packages that `{ggplot2}` also depends on. These packages add no additional
dependency cost because `{ggplot2}` already requires them: `{rlang}`, `{cli}`,
`{scales}`, `{tibble}`, `{vctrs}`, `{withr}`, `{gtable}`, and `{glue}`.
3. Packages that `{ggplot2}` does not depend on. These are all well-maintained
packages with few dependencies and a clear need within `{ggdist}`:
- `{distributional}`: this implementation of distribution vectors powers
much of `{ggdist}`. This package adds minimal additional cost, as its only
dependency that is not also a dependency of `{ggplot2}` is `{numDeriv}`, which
is needed by `{ggdist}` anyway (see below).
- `{numDeriv}`: used for calculating Jacobians of scale transformations.
Needed because testing has revealed common situations where
`stats::numericDeriv()` fails but `{numDeriv}` does not. Widely used by other
CRAN packages and has no additional dependencies.
- `{quadprog}`: Used to solve constrained optimization problems during different
parts of dotplot layout, particularly to avoid dot overlaps in the `"bin"`
and `"weave"` layouts. Widely used by other CRAN packages and has no
additional dependencies.
- `{Rcpp}`: Used to implement faster dotplot layout. Widely used by other CRAN
packages and has no additional dependencies.
## Feedback, issues, and contributions
I welcome feedback, suggestions, issues, and contributions! If you have found a bug, please file it [here](https://github.com/mjskay/ggdist/issues/new) with minimal code to reproduce the issue. Pull requests should be filed against the [`dev`](https://github.com/mjskay/ggdist/tree/dev) branch. I am not particularly reliable over email, though you can try to contact me at . A [Bluesky](https://bsky.app/) message is more likely to elicit a response.
## Citing `ggdist`
Matthew Kay (2024). ggdist: Visualizations of Distributions and Uncertainty in the Grammar of Graphics. _IEEE Transactions on Visualization and Computer Graphics_, 30(1), 414--424. DOI: [10.1109/TVCG.2023.3327195](https://doi.org/10.1109/TVCG.2023.3327195).
Matthew Kay (`r format(Sys.Date(), "%Y")`). ggdist: Visualizations of Distributions and Uncertainty. R package version `r getNamespaceVersion("ggdist")`, . DOI: [10.5281/zenodo.3879620](https://doi.org/10.5281/zenodo.3879620).
Owner
- Name: Matthew Kay
- Login: mjskay
- Kind: user
- Location: Chicago
- Company: Northwestern University
- Website: http://www.mjskay.com/
- Twitter: mjskay
- Repositories: 50
- Profile: https://github.com/mjskay
Assistant Professor at Northwestern; works on human-computer interaction, information visualization, communicating uncertainty
GitHub Events
Total
- Create event: 3
- Release event: 1
- Issues event: 9
- Watch event: 23
- Delete event: 2
- Issue comment event: 24
- Push event: 31
- Pull request review event: 2
- Pull request review comment event: 2
- Pull request event: 3
- Fork event: 4
Last Year
- Create event: 3
- Release event: 1
- Issues event: 9
- Watch event: 23
- Delete event: 2
- Issue comment event: 24
- Push event: 31
- Pull request review event: 2
- Pull request review comment event: 2
- Pull request event: 3
- Fork event: 4
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Matthew Kay | m****y@g****m | 1,720 |
| Timothy Mastny | t****y@g****m | 27 |
| Brenton M. Wiernik | b****k | 21 |
| Teun van den Brand | 4****d | 5 |
| paulsharpeY | 6****Y | 1 |
| James Trimble's ONS work | 7****s | 1 |
| David Gohel | d****l@a****r | 1 |
Committer Domains (Top 20 + Academic)
ardata.fr: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 173
- Total pull requests: 13
- Average time to close issues: 4 months
- Average time to close pull requests: 24 days
- Total issue authors: 62
- Total pull request authors: 9
- Average comments per issue: 2.46
- Average comments per pull request: 1.23
- Merged pull requests: 7
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 12
- Pull requests: 4
- Average time to close issues: about 2 months
- Average time to close pull requests: 18 days
- Issue authors: 11
- Pull request authors: 3
- Average comments per issue: 0.92
- Average comments per pull request: 0.75
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- mjskay (71)
- steveharoz (6)
- fkohrt (6)
- qdread (4)
- DominiqueMakowski (4)
- ASKurz (4)
- arthur-albuquerque (4)
- bwiernik (3)
- davidhodge931 (3)
- Dallak (3)
- joshua-goldberg (2)
- avehtari (2)
- Ari04T (2)
- Bisaloo (2)
- yonisidi (2)
Pull Request Authors
- teunbrand (4)
- MichaelChirico (4)
- bwiernik (2)
- mitchelloharawild (2)
- damonbayer (2)
- CharlesSnt (1)
- mjskay (1)
- davidgohel (1)
- steveharoz (1)
Top Labels
Issue Labels
documentation (14)
enhancement (5)
duplicate (4)
rewrite (2)
high priority (1)
waiting (1)
question (1)
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- cran 25,485 last-month
- Total docker downloads: 52,514
-
Total dependent packages: 27
(may contain duplicates) -
Total dependent repositories: 42
(may contain duplicates) - Total versions: 40
- Total maintainers: 1
proxy.golang.org: github.com/mjskay/ggdist
- Documentation: https://pkg.go.dev/github.com/mjskay/ggdist#section-documentation
- License: gpl-3.0
-
Latest release: v3.3.3+incompatible
published 10 months ago
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced:
6 months ago
cran.r-project.org: ggdist
Visualizations of Distributions and Uncertainty
- Homepage: https://mjskay.github.io/ggdist/
- Documentation: http://cran.r-project.org/web/packages/ggdist/ggdist.pdf
- License: GPL (≥ 3)
-
Latest release: 3.3.3
published 10 months ago
Rankings
Stargazers count: 0.4%
Dependent packages count: 3.1%
Forks count: 3.2%
Downloads: 3.5%
Dependent repos count: 4.1%
Average: 6.1%
Docker downloads count: 22.5%
Maintainers (1)
Last synced:
6 months ago
conda-forge.org: r-ggdist
- Homepage: http://mjskay.github.io/ggdist
- License: GPL-3.0-or-later
-
Latest release: 3.2.0
published over 3 years ago
Rankings
Stargazers count: 14.8%
Dependent packages count: 19.6%
Average: 23.3%
Dependent repos count: 24.4%
Forks count: 34.2%
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.5.0 depends
- HDInterval * imports
- distributional >= 0.3.0 imports
- dplyr >= 1.0.0 imports
- ggplot2 >= 3.3.5 imports
- glue * imports
- grid * imports
- numDeriv * imports
- rlang >= 0.3.0 imports
- scales * imports
- tibble * imports
- tidyselect * imports
- vctrs * imports
- withr * imports
- beeswarm >= 0.4.0 suggests
- broom >= 0.5.6 suggests
- covr * suggests
- cowplot * suggests
- fda * suggests
- forcats * suggests
- gdtools * suggests
- knitr * suggests
- modelr * suggests
- palmerpenguins * suggests
- patchwork * suggests
- pkgdown * suggests
- png * suggests
- posterior * suggests
- purrr >= 0.2.3 suggests
- rmarkdown * suggests
- svglite >= 2.1.0 suggests
- testthat * suggests
- tidyr >= 1.0.0 suggests
- vdiffr >= 1.0.0 suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/cache v1 composite
- actions/checkout v2 composite
- actions/upload-artifact v3 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite