Mosaic Plots in the 'ggplot2' Framework, Extended
Overview
Mosaic plots in the 'ggplot2' framework. Mosaic plot functionality is provided in a single 'ggplot2' layer by calling the geom 'mosaic'. This extends the now-defunct 'ggmosaic' package by allowing fitted loglinear models which can be used to show patterns of association among variables in frequency tables.
- Addressed CRAN review feedback: added
\valuedocumentation to theGeomMosaic,GeomMosaicJitter,GeomMosaicText,StatMosaic,StatMosaicJitter, andStatMosaicTextggproto objects; fixed a brokenprodcalc()example (a straylibrary(productplots)call was masking itsoffsetargument) and unwrapped it; and replaced\dontrunwith\donttestfor the largergeom_mosaic()example block. - Added
facet_mosaic_grid()for mosaic-aware faceting (haleyjeppson/ggmosaic#78): each facet panel gets independent x/y product scales and category axes drawn at panel-specific positions, and it supports multiple mosaic layers,theme_mosaic(),coord_flip(), manual product scales, margins, and residual shading. - Mosaic layers (
geom_mosaic(),geom_mosaic_text(),geom_mosaic_jitter()) now resolve their plot mapping at build time, like ordinaryggplot2layers, so anaes()mapping added or changed after a mosaic layer has already been added is now picked up correctly instead of being frozen at the point the layer was added.
Show all changes in 0.5.1Hide the rest of the changes in 0.5.1
- Added
mosaic_settings()for sharingdivider,offset, andexpectedacross sibling mosaic layers in one plot, so multi-layer plots (e.g.geom_mosaic()+geom_mosaic_text()) no longer need the same argument repeated on every layer. An explicit layer argument, includingexpected = NULL, still overrides the plot-level setting. - Improved Pearson residual shading: negative residuals are now dark red and positive residuals dark blue, with matching dashed/solid cell outlines (disable via
colour = NA, or override colour/linetype/linewidth directly). Added a custom residual legend with signed labels, observed extrema, supplied limits, reference values at -4/0/+4, endpoint colour squishing, and collision-aware ticks/labels, in both vertical and horizontal layouts. - Fixed mosaic spacing:
offsetis now the fixed gap at the deepest split, with gaps increasing by a factor of 1.5 toward outer splits (previously inconsistent), converted to local rectangle coordinates and safely constrained for very small cells;offsetis validated as a single finite, non-negative value. **This changes spacing output relative to earlier versions.** - Fixed namespace-only use (haleyjeppson/ggmosaic#82): calls such as
ggmosaic2::geom_mosaic()andggmosaic2::product()now work withoutlibrary(ggmosaic2). - Variables mapped only to
filloralpha(andcolouringeom_mosaic_jitter()) remain available to the mosaic calculation and point aesthetics, but are no longer shown on the automatic product axes; only variables mapped throughxorcondsare labeled there (haleyjeppson/ggmosaic#39, haleyjeppson/ggmosaic#77). Variables can now be created withingeom_mosaic(), and factors can be reordered for display. theme_mosaic()now passes additional arguments through...toggplot2::theme().- Added the
introducing-ggmosaic2vignette. - Lightened the default
geom_mosaic()tile fill (grey30->grey55). - Fixed
inst/CITATIONfor theggmosaic2fork: retitled fromggmosaic, authors and year are now pulled fromDESCRIPTIONinstead of hardcoded, and a broken multi-URL field is fixed. - Deprecated
ggmosaic_app(), kept only for the historical record. - The
introducing-ggmosaic2vignette was edited for clarity and detail.
From NEWS.md in the release
Install
Health
- OK13 OKNow
- OK5 OK2026-09-17
Documentation
- Help pages
- 33 (6 internal)includes a package overview page
- Examples that run
- 94%17 run in a plain check · 1 never run
- Exported functions with examples
- 75%
- Documented parameters
- 99%
- Return-value docs
- 100%
- Help pages citing references
- 0%
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- not measured
- Median days to close, 50 most recently updated closed PRs
- 0
Commits over time
11 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/friendly/ggmosaic2 on 2026-10-11.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-09-27 · The repository has a site deploy workflow
pkgdown site last built 2026-09-27
Show all practicesHide 2 practices
This repository shows signs of AI coding tools.
- Claude Codefirst seen on or before 2026-07-29Named in .Rbuildignore: .claudeCommits: at least 23 crediting it in the message
- Claude Sonnet 523 commits · Jul to Sep 2026
Dependencies
Installing ggmosaic2 adds 67 packages (37 with compiled code, 64 MB of source tarballs). Heaviest: stringi 11 MB, ggplot2 6.0 MB, data.table 5.7 MB.
Code & Tests
Datasets
People & History
- 0.5.1Latest2026-09-16 · current release
- RR 4.6.0 released · 2026-04-24
Package metadata
- First published
- 2026-09-16
- Total releases
- 1 / 1 yrs
- License
- GPL (>= 2) OSI
- Minimum R
- ≥ 4.1.0
- Bundled data
- 259 KB / 3 files
- Download size
- 1.9 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("ggmosaic2")The package provides a citation file that builds its entry when R runs it. Run citation() to see it.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-19, which the citation names so these numbers can be found later. More on citing and the projects behind them.